detect whether or not user edited the name for a new session
Suprisingly hard/irritating. Thanks, GTK! (Gtk::Entry::set_text() emits all the same signals that actual user interaction can trigger, except for key events)
This commit is contained in:
parent
78cf1ed119
commit
ccc9042bf2
|
@ -79,6 +79,7 @@ using namespace ARDOUR_UI_UTILS;
|
|||
SessionDialog::SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path, const std::string& template_name, bool cancel_not_quit)
|
||||
: ArdourDialog (_("Session Setup"), true, true)
|
||||
, new_only (require_new)
|
||||
, new_name_was_edited (false)
|
||||
, new_folder_chooser (FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
, _existing_session_chooser_used (false)
|
||||
{
|
||||
|
@ -515,6 +516,7 @@ SessionDialog::new_session_button_clicked ()
|
|||
|
||||
new_name_entry.set_text (string_compose (_("Untitled-%1"), tm.format ("%F-%H-%M-%S")));
|
||||
new_name_entry.select_region (0, -1);
|
||||
new_name_was_edited = false;
|
||||
|
||||
back_button->set_sensitive (true);
|
||||
new_name_entry.grab_focus ();
|
||||
|
@ -614,6 +616,7 @@ SessionDialog::setup_new_session_page ()
|
|||
name_hbox->pack_start (*name_label, false, true);
|
||||
name_hbox->pack_start (new_name_entry, true, true);
|
||||
|
||||
new_name_entry.signal_key_press_event().connect (sigc::mem_fun (*this, &SessionDialog::new_name_edited), false);
|
||||
new_name_entry.signal_changed().connect (sigc::mem_fun (*this, &SessionDialog::new_name_changed));
|
||||
new_name_entry.signal_activate().connect (sigc::mem_fun (*this, &SessionDialog::new_name_activated));
|
||||
|
||||
|
@ -695,6 +698,21 @@ SessionDialog::setup_new_session_page ()
|
|||
session_new_vbox.show_all ();
|
||||
}
|
||||
|
||||
bool
|
||||
SessionDialog::new_name_edited (GdkEventKey* ev)
|
||||
{
|
||||
switch (ev->keyval) {
|
||||
case GDK_KP_Enter:
|
||||
case GDK_3270_Enter:
|
||||
case GDK_Return:
|
||||
break;
|
||||
default:
|
||||
new_name_was_edited = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
SessionDialog::new_name_changed ()
|
||||
{
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
|
||||
void set_provided_session (std::string const & name, std::string const & path);
|
||||
void clear_name ();
|
||||
bool was_new_name_edited() const { return new_name_was_edited; }
|
||||
|
||||
private:
|
||||
bool new_only;
|
||||
|
@ -143,6 +144,9 @@ private:
|
|||
|
||||
void setup_new_session_page ();
|
||||
Gtk::Entry new_name_entry;
|
||||
bool new_name_was_edited;
|
||||
bool new_name_edited (GdkEventKey*);
|
||||
|
||||
Gtk::FileChooserButton new_folder_chooser;
|
||||
|
||||
struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
|
||||
|
|
Loading…
Reference in New Issue
Block a user