diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-03-24 00:00:33 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-03-24 14:10:39 -0600 |
commit | ccc9042bf27f47628836dac33a52f71f9af96587 (patch) | |
tree | 1fefbbae47fb3b574cc17065d8b3c4c19aaa5d44 /gtk2_ardour/session_dialog.cc | |
parent | 78cf1ed1194e54348f23ea66ed5d7cc693b2a65d (diff) |
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)
Diffstat (limited to 'gtk2_ardour/session_dialog.cc')
-rw-r--r-- | gtk2_ardour/session_dialog.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc index 42c2182093..46a2e6be8d 100644 --- a/gtk2_ardour/session_dialog.cc +++ b/gtk2_ardour/session_dialog.cc @@ -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 () { |