Use Gtk::Grid for Dialog_Partition_Info (!25)

Gtk::Table was deprecated in Gtk 3.4.0.  Replace with Gtk::Grid.

This commit makes the change for Dialog_Partition_Info.

Closes !25 - Modern Gtk3 - part 1
This commit is contained in:
Luca Bacci 2019-03-13 12:06:22 +01:00 committed by Mike Fleetwood
parent d57d79b1c4
commit 8902b0a260
2 changed files with 135 additions and 198 deletions

View File

@ -28,7 +28,7 @@
#include <gtkmm/frame.h> #include <gtkmm/frame.h>
#include <gtkmm/drawingarea.h> #include <gtkmm/drawingarea.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <gtkmm/table.h>
#define BORDER 8 #define BORDER 8

View File

@ -25,6 +25,7 @@
#include <glibmm/miscutils.h> #include <glibmm/miscutils.h>
#include <gtkmm/alignment.h> #include <gtkmm/alignment.h>
#include <gtkmm/viewport.h> #include <gtkmm/viewport.h>
#include <gtkmm/grid.h>
#include <gdkmm/general.h> #include <gdkmm/general.h>
namespace GParted namespace GParted
@ -237,68 +238,53 @@ void Dialog_Partition_Info::Display_Info()
// file system is accessible. // file system is accessible.
filesystem_accessible = true; filesystem_accessible = true;
//initialize table top and bottom row number attach trackers Gtk::Grid *grid(Gtk::manage(new Gtk::Grid()));
int top = 0 , bottom = 1 ; //Left field & value pairs
int topright = 0, bottomright = 1 ; //Right field & value pairs
Gtk::Table* table(manage(new Gtk::Table())); grid->set_border_width(5);
grid->set_column_spacing(10);
info_msg_vbox.pack_start(*grid, Gtk::PACK_SHRINK);
table ->set_border_width( 5 ) ; // FILE SYSTEM DETAIL SECTION
table ->set_col_spacings(10 ) ; // File system headline
info_msg_vbox .pack_start( *table, Gtk::PACK_SHRINK ) ; grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("File System")) + "</b>"), 0, 0, 6, 1);
//FILE SYSTEM DETAIL SECTION // Initialize grid top attach tracker (left side of the grid)
//file system headline int top = 1;
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("File System") ) + "</b>" ),
0, 6,
top++, bottom++,
Gtk::FILL ) ;
//use current left row tracker position as anchor for right // Left field & value pair area
topright = top ; // File system
bottomright = bottom ; grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("File system:")) + "</b>"), 1, top, 1, 1);
//Left field & value pair area
//file system
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("File system:") ) + "</b>" ),
1, 2,
top, bottom,
Gtk::FILL ) ;
if ( filesystem_accessible ) if ( filesystem_accessible )
{ {
table->attach( *Utils::mk_label( Utils::get_filesystem_string( filesystem_ptn.filesystem ), true, false, true ), grid->attach(*Utils::mk_label(Utils::get_filesystem_string(filesystem_ptn.filesystem), true, false, true),
2, 3, top, bottom, Gtk::FILL ); 2, top, 1, 1);
} }
top++, bottom++; top++;
//label //label
if ( filesystem_ptn.filesystem != FS_UNALLOCATED && filesystem_ptn.type != TYPE_EXTENDED ) if ( filesystem_ptn.filesystem != FS_UNALLOCATED && filesystem_ptn.type != TYPE_EXTENDED )
{ {
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Label:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Label:")) + "</b>"),
1, 2, 1, top, 1, 1);
top, bottom,
Gtk::FILL) ;
if ( filesystem_accessible ) if ( filesystem_accessible )
{ {
table->attach( *Utils::mk_label( filesystem_ptn.get_filesystem_label(), true, false, true ), grid->attach(*Utils::mk_label(filesystem_ptn.get_filesystem_label(), true, false, true),
2, 3, top, bottom, Gtk::FILL); 2, top, 1, 1);
} }
top++, bottom++; top++;
} }
// file system uuid // file system uuid
if ( filesystem_ptn.filesystem != FS_UNALLOCATED && filesystem_ptn.type != TYPE_EXTENDED ) if ( filesystem_ptn.filesystem != FS_UNALLOCATED && filesystem_ptn.type != TYPE_EXTENDED )
{ {
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("UUID:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("UUID:")) + "</b>"),
1, 2, 1, top, 1, 1);
top, bottom,
Gtk::FILL) ;
if ( filesystem_accessible ) if ( filesystem_accessible )
{ {
table->attach( *Utils::mk_label( filesystem_ptn.uuid, true, false, true ), grid->attach(*Utils::mk_label(filesystem_ptn.uuid, true, false, true),
2, 3, top, bottom, Gtk::FILL); 2, top, 1, 1);
} }
top++, bottom++; top++;
} }
/* TO TRANSLATORS: Open /* TO TRANSLATORS: Open
@ -315,9 +301,9 @@ void Dialog_Partition_Info::Display_Info()
{ {
//status //status
Glib::ustring str_temp ; Glib::ustring str_temp ;
table->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Status:")) + "</b>", grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Status:")) + "</b>",
true, false, false, Gtk::ALIGN_START), true, false, false, Gtk::ALIGN_START),
1, 2, top, bottom, Gtk::FILL); 1, top, 1, 1);
if ( ! filesystem_accessible ) if ( ! filesystem_accessible )
{ {
/* TO TRANSLATORS: Not accessible (Encrypted) /* TO TRANSLATORS: Not accessible (Encrypted)
@ -416,27 +402,26 @@ void Dialog_Partition_Info::Display_Info()
str_temp = _("Not mounted") ; str_temp = _("Not mounted") ;
} }
table->attach( *Utils::mk_label( str_temp, true, true, true ), 2, 3, top++, bottom++, Gtk::FILL ); grid->attach(*Utils::mk_label(str_temp, true, true, true), 2, top++, 1, 1);
} }
//Optional, LVM2 Volume Group name //Optional, LVM2 Volume Group name
if ( filesystem_ptn.filesystem == FS_LVM2_PV ) if ( filesystem_ptn.filesystem == FS_LVM2_PV )
{ {
//Volume Group // Volume Group
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Volume Group:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Volume Group:")) + "</b>"),
1, 2, top, bottom, Gtk::FILL ) ; 1, top, 1, 1);
table ->attach( * Utils::mk_label( vgname, true, false, true ), grid->attach(*Utils::mk_label(vgname, true, false, true),
2, 3, top++, bottom++, Gtk::FILL ) ; 2, top++, 1, 1);
} }
//Optional, members of multi-device file systems //Optional, members of multi-device file systems
if ( filesystem_ptn.filesystem == FS_LVM2_PV || if ( filesystem_ptn.filesystem == FS_LVM2_PV ||
filesystem_ptn.filesystem == FS_BTRFS ) filesystem_ptn.filesystem == FS_BTRFS )
{ {
//Members // Members
table->attach(* Utils::mk_label("<b>" + Glib::ustring(_("Members:")) + "</b>", grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Members:")) + "</b>", true, false, false, Gtk::ALIGN_START),
true, false, false, Gtk::ALIGN_START), 1, top, 1, 1);
1, 2, top, bottom, Gtk::FILL);
std::vector<Glib::ustring> members ; std::vector<Glib::ustring> members ;
switch ( filesystem_ptn.filesystem ) switch ( filesystem_ptn.filesystem )
@ -452,22 +437,24 @@ void Dialog_Partition_Info::Display_Info()
break ; break ;
} }
table->attach( *Utils::mk_label( Glib::build_path( "\n", members ), true, false, true ), grid->attach(*Utils::mk_label(Glib::build_path("\n", members), true, false, true),
2, 3, top++, bottom++, Gtk::FILL ); 2, top++, 1, 1);
} }
if ( filesystem_ptn.filesystem == FS_LVM2_PV ) if ( filesystem_ptn.filesystem == FS_LVM2_PV )
{ {
//Logical Volumes // Logical Volumes
table->attach(* Utils::mk_label("<b>" + Glib::ustring(_("Logical Volumes:")) + "</b>", grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Logical Volumes:")) + "</b>", true, false, false, Gtk::ALIGN_START),
true, false, false, Gtk::ALIGN_START), 1, top, 1, 1);
1, 2, top, bottom, Gtk::FILL);
std::vector<Glib::ustring> lvs = LVM2_PV_Info::get_vg_lvs( vgname ); std::vector<Glib::ustring> lvs = LVM2_PV_Info::get_vg_lvs( vgname );
table->attach( *Utils::mk_label( Glib::build_path( "\n", lvs ), true, false, true ), grid->attach(*Utils::mk_label(Glib::build_path("\n", lvs), true, false, true),
2, 3, top++, bottom++, Gtk::FILL ); 2, top++, 1, 1);
} }
// Initialize grid top attach tracker (right side of the grid)
int topright = 1;
//Right field & value pair area //Right field & value pair area
if ( partition .sector_usage_known() ) if ( partition .sector_usage_known() )
{ {
@ -475,186 +462,136 @@ void Dialog_Partition_Info::Display_Info()
int percent_used, percent_unused, percent_unallocated ; int percent_used, percent_unused, percent_unallocated ;
partition .get_usage_triple( 100, percent_used, percent_unused, percent_unallocated ) ; partition .get_usage_triple( 100, percent_used, percent_unused, percent_unallocated ) ;
//Used // Used
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Used:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Used:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::format_size(partition.get_sectors_used(), partition.sector_size), true, false, true),
Gtk::FILL ) ; 4, topright, 1, 1);
table ->attach( * Utils::mk_label( Utils::format_size( partition .get_sectors_used(), partition .sector_size ), true, false, true ), grid->attach(*Utils::mk_label("( " + Utils::num_to_str(percent_used) + "% )"),
4, 5, 5, topright++, 1, 1);
topright, bottomright,
Gtk::FILL ) ;
table ->attach( * Utils::mk_label( "( " + Utils::num_to_str( percent_used ) + "% )"),
5, 6,
topright++, bottomright++,
Gtk::FILL ) ;
//unused // Unused
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Unused:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Unused:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::format_size(partition.get_sectors_unused(), partition.sector_size), true, false, true),
Gtk::FILL ) ; 4, topright, 1, 1);
table ->attach( * Utils::mk_label( Utils::format_size( partition .get_sectors_unused(), partition .sector_size ), true, false, true ), grid->attach(*Utils::mk_label("( " + Utils::num_to_str(percent_unused) + "% )"),
4, 5, 5, topright++, 1, 1);
topright, bottomright,
Gtk::FILL ) ;
table ->attach( * Utils::mk_label( "( " + Utils::num_to_str( percent_unused ) + "% )"),
5, 6,
topright++, bottomright++,
Gtk::FILL ) ;
//unallocated //unallocated
Sector sectors_unallocated = partition .get_sectors_unallocated() ; Sector sectors_unallocated = partition .get_sectors_unallocated() ;
if ( sectors_unallocated > 0 ) if ( sectors_unallocated > 0 )
{ {
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Unallocated:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Unallocated:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::format_size(sectors_unallocated, partition.sector_size), true, false, true),
Gtk::FILL ) ; 4, topright, 1, 1);
table ->attach( * Utils::mk_label( Utils::format_size( sectors_unallocated, partition .sector_size ), true, false, true ), grid->attach(*Utils::mk_label("( " + Utils::num_to_str(percent_unallocated) + "% )"),
4, 5, 5, topright++, 1, 1);
topright, bottomright,
Gtk::FILL ) ;
table ->attach( * Utils::mk_label( "( " + Utils::num_to_str( percent_unallocated ) + "% )"),
5, 6,
topright++, bottomright++,
Gtk::FILL ) ;
} }
} }
//size // Size
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Size:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Size:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::format_size(ptn_sectors, partition.sector_size), true, false, true),
Gtk::FILL) ; 4, topright++, 1, 1);
table ->attach( * Utils::mk_label( Utils::format_size( ptn_sectors, partition .sector_size ), true, false, true ),
4, 5,
topright++, bottomright++,
Gtk::FILL ) ;
//ensure left row tracker set to largest side (left/right) //ensure left row tracker set to largest side (left/right)
top = std::max( top, topright ); top = std::max( top, topright );
bottom = std::max( bottom, bottomright );
//one blank line // One blank line
table ->attach( * Utils::mk_label( "" ), 0, 6, top++, bottom++, Gtk::FILL ) ; grid->attach(*Utils::mk_label(""), 0, top++, 6, 1);
if ( partition.filesystem == FS_LUKS ) if ( partition.filesystem == FS_LUKS )
{ {
// ENCRYPTION DETAIL SECTION // ENCRYPTION DETAIL SECTION
// encryption headline // Encryption headline
table->attach( *Utils::mk_label( "<b>" + Glib::ustring( _("Encryption") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Encryption")) + "</b>"),
0, 6, top++, bottom++, Gtk::FILL ); 0, top++, 6, 1);
// Encryption // Encryption
table->attach( *Utils::mk_label( "<b>" + Glib::ustring( _("Encryption:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Encryption:")) + "</b>"),
1, 2, top, bottom, Gtk::FILL); 1, top, 1, 1);
table->attach( *Utils::mk_label( Utils::get_filesystem_string( partition.filesystem ), true, false, true ), grid->attach(*Utils::mk_label(Utils::get_filesystem_string(partition.filesystem), true, false, true),
2, 3, top++, bottom++, Gtk::FILL); 2, top++, 1, 1);
// LUKS path // LUKS path
table->attach( *Utils::mk_label( "<b>" + Glib::ustring( _("Path:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Path:")) + "</b>"),
1, 2, top, bottom, Gtk::FILL); 1, top, 1, 1);
if ( partition.busy ) if ( partition.busy )
table->attach( *Utils::mk_label( partition.get_mountpoint(), true, false, true ), grid->attach(*Utils::mk_label(partition.get_mountpoint(), true, false, true),
2, 3, top, bottom, Gtk::FILL); 2, top, 1, 1);
top++, bottom++; top++;
// LUKS uuid // LUKS uuid
table->attach( *Utils::mk_label( "<b>" + Glib::ustring( _("UUID:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("UUID:")) + "</b>"),
1, 2, top, bottom, Gtk::FILL); 1, top, 1, 1);
table->attach( *Utils::mk_label( partition.uuid, true, false, true ), grid->attach(*Utils::mk_label(partition.uuid, true, false, true),
2, 3, top++, bottom++, Gtk::FILL); 2, top++, 1, 1);
// LUKS status // LUKS status
table->attach( *Utils::mk_label( "<b>" + Glib::ustring( _("Status:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Status:")) + "</b>"),
1, 2, top, bottom, Gtk::FILL ); 1, top, 1, 1);
Glib::ustring str_temp; Glib::ustring str_temp;
if ( partition.busy ) if ( partition.busy )
str_temp = luks_open; str_temp = luks_open;
else else
str_temp = luks_closed; str_temp = luks_closed;
table->attach( *Utils::mk_label( str_temp, true, false, true ), 2, 3, top++, bottom++, Gtk::FILL ); grid->attach(*Utils::mk_label(str_temp, true, false, true), 2, top++, 1, 1);
// one blank line // One blank line
table->attach( *Utils::mk_label( "" ), 0, 6, top++, bottom++, Gtk::FILL ); grid->attach(*Utils::mk_label(""), 0, top++, 6, 1);
} }
//PARTITION DETAIL SECTION // PARTITION DETAIL SECTION
//partition headline // Partition headline
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Partition") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Partition")) + "</b>"),
0, 6, 0, top++, 6, 1);
top++, bottom++,
Gtk::FILL ) ;
//use current left row tracker position as anchor for right //use current left row tracker position as anchor for right
topright = top ; topright = top ;
bottomright = bottom ;
//Left field & value pair area // Left field & value pair area
//path // Path
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Path:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Path:")) + "</b>"),
1, 2, 1, top, 1, 1);
top, bottom, grid->attach(*Utils::mk_label(partition.get_path(), true, false, true),
Gtk::FILL ) ; 2, top++, 1, 1);
table->attach( * Utils::mk_label( partition.get_path(), true, false, true ),
2, 3,
top++, bottom++,
Gtk::FILL );
if (partition.filesystem != FS_UNALLOCATED && partition.status != STAT_NEW) if (partition.filesystem != FS_UNALLOCATED && partition.status != STAT_NEW)
{ {
// name // Name
table->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Name:") ) + "</b>"), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Name:")) + "</b>"),
1, 2, 1, top, 1, 1);
top, bottom, grid->attach(*Utils::mk_label(partition.name, true, false, true),
Gtk::FILL ); 2, top++, 1, 1);
table->attach( * Utils::mk_label( partition.name, true, false, true ),
2, 3,
top++, bottom++,
Gtk::FILL );
// flags // Flags
table->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Flags:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Flags:")) + "</b>"),
1, 2, 1, top, 1, 1);
top, bottom, grid->attach(*Utils::mk_label(Glib::build_path(", ", partition.flags), true, false, true),
Gtk::FILL ); 2, top++, 1, 1);
table->attach( * Utils::mk_label( Glib::build_path( ", ", partition .flags ), true, false, true ),
2, 3,
top++, bottom++,
Gtk::FILL );
} }
//Right field & value pair area // Right field & value pair area
//first sector // First sector
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("First sector:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("First sector:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::num_to_str(partition.sector_start), true, false, true),
Gtk::FILL ) ; 4, topright++, 1, 1);
table ->attach( * Utils::mk_label( Utils::num_to_str( partition .sector_start ), true, false, true ),
4, 5,
topright++, bottomright++,
Gtk::FILL ) ;
//last sector // Last sector
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Last sector:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Last sector:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::num_to_str(partition.sector_end), true, false, true),
Gtk::FILL ) ; 4, topright++, 1, 1);
table ->attach( * Utils::mk_label( Utils::num_to_str( partition.sector_end ), true, false, true ),
4, 5,
topright++, bottomright++,
Gtk::FILL ) ;
//total sectors // Total sectors
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Total sectors:") ) + "</b>" ), grid->attach(*Utils::mk_label("<b>" + Glib::ustring(_("Total sectors:")) + "</b>"),
3, 4, 3, topright, 1, 1);
topright, bottomright, grid->attach(*Utils::mk_label(Utils::num_to_str(ptn_sectors), true, false, true),
Gtk::FILL ) ; 4, topright++, 1, 1);
table ->attach( * Utils::mk_label( Utils::num_to_str( ptn_sectors ), true, false, true ),
4, 5,
topright++, bottomright++,
Gtk::FILL ) ;
} }
Dialog_Partition_Info::~Dialog_Partition_Info() Dialog_Partition_Info::~Dialog_Partition_Info()