From ccc9042bf27f47628836dac33a52f71f9af96587 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 24 Mar 2020 00:00:33 -0600 Subject: 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) --- gtk2_ardour/session_dialog.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gtk2_ardour/session_dialog.cc') 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 () { -- cgit v1.2.3