diff options
author | Nick Mainsbridge <beatroute@iprimus.com.au> | 2006-04-22 15:28:59 +0000 |
---|---|---|
committer | Nick Mainsbridge <beatroute@iprimus.com.au> | 2006-04-22 15:28:59 +0000 |
commit | dcd4c89f34f51e3a65f01584f79d6569ccc3b1b1 (patch) | |
tree | 592436821dcd315f0709b7fad071b367226c260f /libs/gtkmm2ext/prompter.cc | |
parent | f81f877adffccffd5ada8431faa567db81122fee (diff) |
Prompter now prevents blank strings or unaltered names & now has a horizontal orientation. Rename marker now uses the ArdourPrompter.
git-svn-id: svn://localhost/trunk/ardour2@463 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext/prompter.cc')
-rw-r--r-- | libs/gtkmm2ext/prompter.cc | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/libs/gtkmm2ext/prompter.cc b/libs/gtkmm2ext/prompter.cc index 508e509868..c3a04f19a8 100644 --- a/libs/gtkmm2ext/prompter.cc +++ b/libs/gtkmm2ext/prompter.cc @@ -48,14 +48,15 @@ Prompter::init () set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG); set_position (Gtk::WIN_POS_MOUSE); set_name ("Prompter"); - - set_default_response (Gtk::RESPONSE_ACCEPT); add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); /* Alas a generic 'affirmative' button seems a bit useless sometimes. You will have to add your own. + After adding, use : + set_response_sensitive (Gtk::RESPONSE_ACCEPT, false) + to prevent the RESPONSE_ACCEPT button from permitting blank strings. */ entryLabel.set_line_wrap (true); @@ -69,7 +70,7 @@ Prompter::init () get_vbox()->pack_start (entryBox); show_all_children(); - + entry.signal_key_release_event().connect (mem_fun (*this, &Prompter::maybe_allow_response)); entry.signal_activate().connect (bind (mem_fun (*this, &Prompter::response), Gtk::RESPONSE_ACCEPT)); } @@ -88,3 +89,23 @@ Prompter::get_result (string &str, bool strip) strip_whitespace_edges (str); } } + +bool +Prompter::maybe_allow_response (GdkEventKey* ev) +{ + /* + This is set up so that entering text in the entry + field makes the RESPONSE_ACCEPT button active. + Of course if you haven't added a RESPONSE_ACCEPT + button, nothing will happen at all. + */ + + if (entry.get_text() != "") { + set_response_sensitive (Gtk::RESPONSE_ACCEPT, true); + set_default_response (Gtk::RESPONSE_ACCEPT); + } else { + set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); + } + return true; +} + |