From d57d79b1c457b83e57ba1e81e791435b6f283196 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 7 Mar 2019 11:44:05 +0100 Subject: [PATCH] Use Gtk::Grid for Win_GParted pt2 (!25) Gtk::Table was deprecated in Gtk 3.4.0. Replace with Gtk::Grid. This commit makes the change for Win_GParted / pt2. Closes !25 - Modern Gtk3 - part 1 --- include/Win_GParted.h | 3 +- src/Win_GParted.cc | 154 +++++++++++++++++++----------------------- 2 files changed, 69 insertions(+), 88 deletions(-) diff --git a/include/Win_GParted.h b/include/Win_GParted.h index ff2b37f9..77ed138e 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -35,7 +35,7 @@ #include #include #include -#include + namespace GParted { @@ -230,7 +230,6 @@ private: Gtk::Statusbar statusbar; Gtk::Image *image ; Gtk::ScrolledWindow *scrollwindow; - Gtk::Table *table ; Gtk::ProgressBar pulsebar ; Gtk::TreeRow treerow; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 76cffa45..71d18553 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -567,106 +567,88 @@ void Win_GParted::init_device_info() { vbox_info.set_orientation(Gtk::ORIENTATION_VERTICAL); vbox_info.set_spacing( 5 ); - int top = 0, bottom = 1; - + int top = 0; + //title vbox_info .pack_start( * Utils::mk_label( " " + static_cast( _("Device Information") ) + "" ), Gtk::PACK_SHRINK ); - + //GENERAL DEVICE INFO - table = manage( new Gtk::Table() ) ; - table ->set_col_spacings( 10 ) ; - - //model - table ->attach( * Utils::mk_label( " " + static_cast( _("Model:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; + Gtk::Grid *grid = manage(new Gtk::Grid()); + grid->set_column_spacing(10); + + // Model + grid->attach(*Utils::mk_label(" " + static_cast(_("Model:")) + ""), + 0, top, 1, 1); device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); // Serial number - table->attach( *Utils::mk_label( " " + static_cast( _("Serial:") ) + "" ), - 0, 1, top, bottom, Gtk::FILL ); + grid->attach(*Utils::mk_label(" " + static_cast(_("Serial:")) + ""), + 0, top, 1, 1); device_info.push_back( Utils::mk_label( "", true, false, true ) ); - table->attach( *device_info.back(), 1, 2, top++, bottom++, Gtk::FILL ); + grid->attach(*device_info.back(), 1, top++, 1, 1); - //size - table ->attach( * Utils::mk_label( " " + static_cast( _("Size:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; + // Size + grid->attach(*Utils::mk_label(" " + static_cast(_("Size:")) + ""), + 0, top, 1, 1); device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; - - //path - table ->attach( * Utils::mk_label( " " + static_cast( _("Path:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; - - vbox_info .pack_start( *table, Gtk::PACK_SHRINK ); - - //DETAILED DEVICE INFO - top = 0 ; bottom = 1; - table = manage( new Gtk::Table() ) ; - table ->set_col_spacings( 10 ) ; - - //one blank line - table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ); - - //disktype - table ->attach( * Utils::mk_label( " " + static_cast( _("Partition table:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ); - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; - - //heads - table ->attach( * Utils::mk_label( " " + static_cast( _("Heads:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; - - //sectors/track - table ->attach( * Utils::mk_label( " " + static_cast( _("Sectors/track:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ); - - //cylinders - table ->attach( * Utils::mk_label( " " + static_cast( _("Cylinders:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ) ; - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; - - //total sectors - table ->attach( * Utils::mk_label( " " + static_cast( _("Total sectors:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ); - device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); - //sector size - table ->attach( * Utils::mk_label( " " + static_cast( _("Sector size:") ) + "" ), - 0, 1, - top, bottom, - Gtk::FILL ); + // Path + grid->attach(*Utils::mk_label(" " + static_cast(_("Path:")) + ""), + 0, top, 1, 1); device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; - table ->attach( * device_info .back(), 1, 2, top++, bottom++, Gtk::FILL ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); - vbox_info .pack_start( *table, Gtk::PACK_SHRINK ); + vbox_info.pack_start(*grid, Gtk::PACK_SHRINK); + + //DETAILED DEVICE INFO + top = 0; + grid = manage(new Gtk::Grid()); + grid->set_column_spacing(10); + + // One blank line + grid->attach(*Utils::mk_label(""), 1, top++, 1, 1); + + // Disktype + grid->attach(*Utils::mk_label(" " + static_cast(_("Partition table:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + // Heads + grid->attach(*Utils::mk_label(" " + static_cast(_("Heads:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + // Sectors / track + grid->attach(*Utils::mk_label(" " + static_cast(_("Sectors/track:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + // Cylinders + grid->attach(*Utils::mk_label(" " + static_cast(_("Cylinders:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + // Total sectors + grid->attach(*Utils::mk_label(" " + static_cast(_("Total sectors:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + // Sector size + grid->attach(*Utils::mk_label(" " + static_cast(_("Sector size:")) + ""), + 0, top, 1, 1); + device_info .push_back( Utils::mk_label( "", true, false, true ) ) ; + grid->attach(*device_info.back(), 1, top++, 1, 1); + + vbox_info.pack_start(*grid, Gtk::PACK_SHRINK); } void Win_GParted::init_hpaned_main()