From f760c16ba60b690f168b7a0b7f3ec764f93caefa Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Tue, 15 May 2018 07:34:43 +0100 Subject: [PATCH] Simplify from Gtk::Table to HBox in FileSystem Label dialog The FileSystem Label dialog only has a single line of just 2 widgets; a text label and entry box widget. There is no need to use a multi-line capable table to hold this. Switch to a simpler horizontal box widget. Note that this change is not related to porting to Gtk 3 and stopping using deprecated APIs because both HBox [1] and Table [2] are deprecated in Gtk 3.2 and Gtk 3.4 and replaced by Box with horizontal orientation and Grid respectively. [1] NEWS file from gtkmm 3.2, actually first released in gtkmm 3.1.6 (unstable): https://git.gnome.org/browse/gtkmm/tree/NEWS?h=3.2.0#n91 "Gtk: * All H* or V* specialized classes have been deprecated, to match the deprecations in the GTK+ C API. You should now set the orientation instead. This includes HBox, VBox, HButtonBox, VButtonBox, HPaned, VPaned, HScale, VScale, HSeparator, VSeparator, HScrollbar and VScrollbar." [2] NEWS file from gtkmm 3.4, actually first released in gtkmm 3.3.2 (unstable): https://git.gnome.org/browse/gtkmm/tree/NEWS?h=3.4.0#n162 "* Deprecate Gtk::Table in favour of Gtk::Grid." --- include/Dialog_FileSystem_Label.h | 6 +---- src/Dialog_FileSystem_Label.cc | 45 ++++++++++++++----------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/include/Dialog_FileSystem_Label.h b/include/Dialog_FileSystem_Label.h index 094f01aa..b5bba685 100644 --- a/include/Dialog_FileSystem_Label.h +++ b/include/Dialog_FileSystem_Label.h @@ -20,14 +20,10 @@ #include "Partition.h" #include "i18n.h" +#include #include -#include -#include -#include #include -#define BORDER 8 - namespace GParted { diff --git a/src/Dialog_FileSystem_Label.cc b/src/Dialog_FileSystem_Label.cc index a64aa63c..f84c25a5 100644 --- a/src/Dialog_FileSystem_Label.cc +++ b/src/Dialog_FileSystem_Label.cc @@ -17,6 +17,11 @@ #include "Dialog_FileSystem_Label.h" #include "Partition.h" +#include +#include +#include +#include + namespace GParted { @@ -29,32 +34,22 @@ Dialog_FileSystem_Label::Dialog_FileSystem_Label( const Partition & partition ) /* TO TRANSLATORS: dialog title, looks like Set file system label on /dev/hda3 */ this->set_title( String::ucompose( _("Set file system label on %1"), partition.get_path() ) ); - { - int top = 0, bottom = 1; + // HBox to hold the label and entry box line + Gtk::HBox *hbox( manage( new Gtk::HBox() ) ); + hbox->set_border_width( 5 ); + hbox->set_spacing( 10 ); + get_vbox()->pack_start( *hbox, Gtk::PACK_SHRINK ); - //Create table to hold Label and entry box - Gtk::Table* table(manage(new Gtk::Table())); - - table->set_border_width(5); - table->set_col_spacings(10); - get_vbox()->pack_start(*table, Gtk::PACK_SHRINK); - table->attach(*Utils::mk_label("" + Glib::ustring(_("Label:")) + ""), - 0, 1, - top, bottom, - Gtk::FILL); - //Create Text entry box - entry = manage(new Gtk::Entry()); - entry->set_max_length( Utils::get_filesystem_label_maxlength( partition.filesystem ) ) ; - entry->set_width_chars( 30 ); - entry->set_activates_default(true); - entry->set_text(partition.get_filesystem_label()); - entry->select_region(0, entry ->get_text_length()); - //Add entry box to table - table->attach(*entry, - 1, 2, - top++, bottom++, - Gtk::FILL); - } + // Only line: "Label: [EXISTINGLABEL ]" + hbox->pack_start( *Utils::mk_label("" + Glib::ustring( _("Label:") ) + ""), + Gtk::PACK_SHRINK ); + entry = manage( new Gtk::Entry() ); + entry->set_max_length( Utils::get_filesystem_label_maxlength( partition.filesystem ) ); + entry->set_width_chars( 30 ); + entry->set_activates_default( true ); + entry->set_text( partition.get_filesystem_label() ); + entry->select_region( 0, entry->get_text_length() ); + hbox->pack_start( *entry, Gtk::PACK_SHRINK ); this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ) ; this ->add_button( Gtk::Stock::OK, Gtk::RESPONSE_OK ) ;