Setting default button for rename dialog, fixes #5266
Bug fixes: - No event is now raised when user presses OK button or ENTER key without changing spot name - Some code cleanup
This commit is contained in:
@@ -424,12 +424,14 @@ void ControlSpotPanel::on_button_rename()
|
|||||||
int status = d.run();
|
int status = d.run();
|
||||||
|
|
||||||
// Update actual name and raise event
|
// Update actual name and raise event
|
||||||
if (status == 1) {
|
if (status == RenameDialog::OkButton) {
|
||||||
nameChanged_ = true;
|
const Glib::ustring newname = d.get_new_name();
|
||||||
const auto newname = d.get_new_name();
|
if (newname != actualname) { // Event is only raised if name is updated
|
||||||
row[spots_.name] = newname;
|
nameChanged_ = true;
|
||||||
treeview_.columns_autosize();
|
row[spots_.name] = newname;
|
||||||
listener->panelChanged(EvLocallabSpotName, newname);
|
treeview_.columns_autosize();
|
||||||
|
listener->panelChanged(EvLocallabSpotName, newname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2134,23 +2136,29 @@ ControlSpotPanel::ControlSpots::ControlSpots()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ControlSpotPanel::RenameDialog::RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent):
|
ControlSpotPanel::RenameDialog::RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent):
|
||||||
Gtk::Dialog(M("TP_LOCALLAB_REN_DIALOG_NAME"), parent)
|
Gtk::Dialog(M("TP_LOCALLAB_REN_DIALOG_NAME"), parent),
|
||||||
|
|
||||||
|
newname_(Gtk::manage(new Gtk::Entry()))
|
||||||
{
|
{
|
||||||
Gtk::HBox *hb = Gtk::manage(new Gtk::HBox());
|
// Entry widget
|
||||||
|
Gtk::HBox* const hb = Gtk::manage(new Gtk::HBox());
|
||||||
hb->pack_start(*Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_REN_DIALOG_LAB"))), false, false, 4);
|
hb->pack_start(*Gtk::manage(new Gtk::Label(M("TP_LOCALLAB_REN_DIALOG_LAB"))), false, false, 4);
|
||||||
|
newname_->set_text(actualname);
|
||||||
newname_.set_text(actualname);
|
hb->pack_start(*newname_);
|
||||||
hb->pack_start(newname_);
|
|
||||||
|
|
||||||
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
|
get_content_area()->pack_start(*hb, Gtk::PACK_SHRINK, 4);
|
||||||
|
|
||||||
add_button(M("GENERAL_OK"), 1);
|
// OK/CANCEL buttons
|
||||||
add_button(M("GENERAL_CANCEL"), 2);
|
add_button(M("GENERAL_OK"), OkButton);
|
||||||
|
add_button(M("GENERAL_CANCEL"), CancelButton);
|
||||||
|
|
||||||
|
// Set OK button as default one when pressing enter
|
||||||
|
newname_->set_activates_default();
|
||||||
|
set_default_response(OkButton);
|
||||||
|
|
||||||
show_all_children();
|
show_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring ControlSpotPanel::RenameDialog::get_new_name()
|
Glib::ustring ControlSpotPanel::RenameDialog::get_new_name()
|
||||||
{
|
{
|
||||||
return newname_.get_text();
|
return newname_->get_text();
|
||||||
}
|
}
|
||||||
|
@@ -294,11 +294,16 @@ private:
|
|||||||
public Gtk::Dialog
|
public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum DialogButton {
|
||||||
|
OkButton = 1,
|
||||||
|
CancelButton = 2
|
||||||
|
};
|
||||||
|
|
||||||
RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent);
|
RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent);
|
||||||
Glib::ustring get_new_name();
|
Glib::ustring get_new_name();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::Entry newname_;
|
Gtk::Entry* const newname_;
|
||||||
};
|
};
|
||||||
|
|
||||||
ControlSpots spots_;
|
ControlSpots spots_;
|
||||||
|
Reference in New Issue
Block a user