Simplify from Gtk::Table to HBox in Partition Name dialog

Same case as for FileSystem Label dialog before; the Partition Name
dialog only has a single line of just 2 widgets.  Therefore switch to a
simpler horizontal box widget to lay them out.
This commit is contained in:
Mike Fleetwood 2018-05-16 16:29:32 +01:00 committed by Curtis Gedak
parent f760c16ba6
commit eab54260a4
2 changed files with 25 additions and 31 deletions

View File

@ -20,9 +20,8 @@
#include "Partition.h"
#include "i18n.h"
#include <glibmm/ustring.h>
#include <gtkmm/dialog.h>
#include <gtkmm/stock.h>
#include <gtkmm/table.h>
#include <gtkmm/entry.h>
namespace GParted

View File

@ -17,6 +17,11 @@
#include "Dialog_Partition_Name.h"
#include "Partition.h"
#include <glibmm/ustring.h>
#include <gtkmm/box.h>
#include <gtkmm/stock.h>
#include <gtkmm/entry.h>
namespace GParted
{
@ -29,38 +34,28 @@ Dialog_Partition_Name::Dialog_Partition_Name( const Partition & partition, int m
/* TO TRANSLATORS: dialog title, looks like Set partition name on /dev/hda3 */
this->set_title( String::ucompose( _("Set partition name on %1"), partition.get_path() ) );
{
int top = 0, bottom = 1;
// HBox to hole 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 name and entry box
Gtk::Table *table( manage( new Gtk::Table() ) );
// Only line: "Name: [EXISTINGNAME ]"
hbox->pack_start( *Utils::mk_label( "<b>" + Glib::ustring(_("Name:")) + "</b>" ),
Gtk::PACK_SHRINK );
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(_("Name:")) + "</b>" ),
0, 1,
top, bottom,
Gtk::FILL );
// Create text entry box
entry = manage( new Gtk::Entry() );
entry = manage( new Gtk::Entry() );
// NOTE: This limits the Gtk::Entry size in UTF-8 characters but partition names
// are defined in terms of ASCII characters, or for GPT, UTF-16LE code points.
// See Utils::get_max_partition_name_length(). So for certain extended characters
// this limit will be too generous.
entry->set_max_length( max_length );
// NOTE: This limits the Gtk::Entry size in UTF-8 characters but partition
// names are defined in terms of ASCII characters, or for GPT, UTF-16LE
// code points. See Utils::get_max_partition_name_length(). So for
// certain extended characters this limit will be too generous.
entry->set_max_length( max_length );
entry->set_width_chars( 30 );
entry->set_activates_default( true );
entry->set_text( partition.name );
entry->select_region( 0, entry->get_text_length() );
// Add entry box to table
table->attach( *entry,
1, 2,
top++, bottom++,
Gtk::FILL );
}
entry->set_width_chars( 30 );
entry->set_activates_default( true );
entry->set_text( partition.name );
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 );