Use Gtk::Grid for Dialog_Partition_New (!25)

Gtk::Table was deprecated in Gtk 3.4.0 [1].  Replace with Gtk::Grid.
Note that the meaning of the attachment parameters changed between
Gtk::Table::attach() [2] from left, right, top, bottom and
Gtk::Grid::attach() [3] to left, top, width, height.

This commit makes the change for Dialog_Base_Partition.

[1] Gtkmm 3.4 NEWS file (actually first included in gtkmm 3.3.2
    unstable)
    https://gitlab.gnome.org/GNOME/gtkmm/blob/3.4.0/NEWS#L162
        * Deprecate Gtk::Table in favour of Gtk::Grid.

[2] Gtkmm 3.4 Gtk::Table Class Reference, attach() method
    https://developer.gnome.org/gtkmm/3.4/classGtk_1_1Table.html#a28b6926e68337a51ba29f2b4dd69f087
        Deprecated: 3.4: Use Gtk::Grid::attach() with Gtk:Grid.  Note
        that the attach argument differ between those two function.

[3] Gtkmm 3.4 Gtk::Grid Class Reference, attach() method
    https://developer.gnome.org/gtkmm/3.4/classGtk_1_1Grid.html#a9c425e95660daff60a77fc0cafc18115

Closes !25 - Modern Gtk3 - part 1
This commit is contained in:
Luca Bacci 2019-03-06 15:43:36 +01:00 committed by Mike Fleetwood
parent 1bee0ddf26
commit 90b3e99554
2 changed files with 32 additions and 23 deletions

View File

@ -24,6 +24,9 @@
#include "Partition.h" #include "Partition.h"
#include "Utils.h" #include "Utils.h"
#include <gtkmm/grid.h>
namespace GParted namespace GParted
{ {
@ -52,7 +55,7 @@ private:
void build_filesystems_combo(bool only_unformatted); void build_filesystems_combo(bool only_unformatted);
Byte_Value get_filesystem_min_limit( FSType fstype ); Byte_Value get_filesystem_min_limit( FSType fstype );
Gtk::Table table_create; Gtk::Grid grid_create;
OptionComboBox combo_type; OptionComboBox combo_type;
OptionComboBox combo_filesystem; OptionComboBox combo_filesystem;
Gtk::Entry partition_name_entry; Gtk::Entry partition_name_entry;

View File

@ -21,6 +21,9 @@
#include "Partition.h" #include "Partition.h"
#include "Utils.h" #include "Utils.h"
#include <glibmm/ustring.h>
namespace GParted namespace GParted
{ {
@ -89,16 +92,15 @@ void Dialog_Partition_New::set_data( const Device & device,
fs_tmp.filesystem = FS_EXTENDED; fs_tmp.filesystem = FS_EXTENDED;
fs_tmp.create = FS::NONE; fs_tmp.create = FS::NONE;
this ->FILESYSTEMS .push_back( fs_tmp ) ; this ->FILESYSTEMS .push_back( fs_tmp ) ;
//add table with selection menu's... // Add table with selection menu's...
table_create .set_border_width( 10 ) ; grid_create.set_border_width(10);
table_create .set_row_spacings( 5 ) ; grid_create.set_row_spacing(5);
hbox_main .pack_start( table_create, Gtk::PACK_SHRINK ); hbox_main.pack_start(grid_create, Gtk::PACK_SHRINK);
/* TO TRANSLATORS: used as label for a list of choices. Create as: <combo box with choices> */ /* TO TRANSLATORS: used as label for a list of choices. Create as: <combo box with choices> */
table_create .attach( * Utils::mk_label( static_cast<Glib::ustring>( _("Create as:") ) + "\t" ), grid_create.attach(*Utils::mk_label(Glib::ustring(_("Create as:")) + "\t"),
0, 1, 0, 1, 0, 0, 1, 1);
Gtk::FILL );
// Fill partition type combo. // Fill partition type combo.
combo_type.items().push_back(_("Primary Partition")); combo_type.items().push_back(_("Primary Partition"));
@ -132,35 +134,39 @@ void Dialog_Partition_New::set_data( const Device & device,
combo_type.signal_changed().connect( combo_type.signal_changed().connect(
sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::combobox_changed), true)); sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::combobox_changed), true));
table_create.attach(combo_type, 1, 2, 0, 1, Gtk::FILL); grid_create.attach(combo_type, 1, 0, 1, 1);
// Partition name // Partition name
table_create.attach( *Utils::mk_label( static_cast<Glib::ustring>( _("Partition name:") ) + "\t" ), grid_create.attach(*Utils::mk_label(Glib::ustring(_("Partition name:")) + "\t"),
0, 1, 1, 2, Gtk::FILL ); 0, 1, 1, 1);
// Initialise text entry box // Initialise text entry box
partition_name_entry.set_width_chars( 20 ); partition_name_entry.set_width_chars( 20 );
partition_name_entry.set_sensitive( device.partition_naming_supported() ); partition_name_entry.set_sensitive( device.partition_naming_supported() );
partition_name_entry.set_max_length( device.get_max_partition_name_length() ); partition_name_entry.set_max_length( device.get_max_partition_name_length() );
// Add entry box to table // Add entry box to table
table_create .attach( partition_name_entry, 1, 2, 1, 2, Gtk::FILL ); grid_create.attach(partition_name_entry, 1, 1, 1, 1);
//file systems to choose from // File systems to choose from
table_create .attach( * Utils::mk_label( static_cast<Glib::ustring>( _("File system:") ) + "\t" ), grid_create.attach(*Utils::mk_label(Glib::ustring(_("File system:")) + "\t"),
0, 1, 2, 3, Gtk::FILL ); 0, 1, 2, 3);
build_filesystems_combo(device.readonly); build_filesystems_combo(device.readonly);
combo_filesystem.signal_changed().connect( combo_filesystem.signal_changed().connect(
sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::combobox_changed), false)); sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::combobox_changed), false));
table_create.attach(combo_filesystem, 1, 2, 2, 3, Gtk::FILL); grid_create.attach(combo_filesystem, 1, 2, 1, 1);
//Label // Label
table_create .attach( * Utils::mk_label( Glib::ustring( _("Label:") ) ), grid_create.attach(*Utils::mk_label(_("Label:")), 0, 3, 1, 1);
0, 1, 3, 4, Gtk::FILL );
//Create Text entry box //Create Text entry box
filesystem_label_entry.set_width_chars( 20 ); filesystem_label_entry.set_width_chars( 20 );
//Add entry box to table // Add entry box to table
table_create.attach( filesystem_label_entry, 1, 2, 3, 4, Gtk::FILL ); grid_create.attach(filesystem_label_entry, 1, 3, 1, 1);
// Set vexpand on all grid_create child widgets
std::vector<Gtk::Widget*> children = grid_create.get_children();
for (std::vector<Gtk::Widget*>::iterator it = children.begin(); it != children.end(); ++it)
(*it)->set_vexpand();
//set some widely used values... //set some widely used values...
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ); MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition );