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."
This commit is contained in:
Mike Fleetwood 2018-05-15 07:34:43 +01:00 committed by Curtis Gedak
parent d948cbcb91
commit f760c16ba6
2 changed files with 21 additions and 30 deletions

View File

@ -20,14 +20,10 @@
#include "Partition.h"
#include "i18n.h"
#include <glibmm/ustring.h>
#include <gtkmm/dialog.h>
#include <gtkmm/stock.h>
#include <gtkmm/frame.h>
#include <gtkmm/table.h>
#include <gtkmm/entry.h>
#define BORDER 8
namespace GParted
{

View File

@ -17,6 +17,11 @@
#include "Dialog_FileSystem_Label.h"
#include "Partition.h"
#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <gtkmm/stock.h>
#include <gtkmm/entry.h>
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("<b>" + Glib::ustring(_("Label:")) + "</b>"),
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("<b>" + Glib::ustring( _("Label:") ) + "</b>"),
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 ) ;