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 | |
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')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/prompter.h | 3 | ||||
-rw-r--r-- | libs/gtkmm2ext/prompter.cc | 27 |
2 files changed, 26 insertions, 4 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/prompter.h b/libs/gtkmm2ext/gtkmm2ext/prompter.h index 795d982295..9847e73661 100644 --- a/libs/gtkmm2ext/gtkmm2ext/prompter.h +++ b/libs/gtkmm2ext/gtkmm2ext/prompter.h @@ -54,13 +54,14 @@ class Prompter : public Gtk::Dialog void change_labels (std::string ok, std::string cancel); void get_result (std::string &str, bool strip=true); + bool maybe_allow_response (GdkEventKey* ); protected: Gtk::Entry& the_entry() { return entry; } private: Gtk::Entry entry; - Gtk::VBox entryBox; + Gtk::HBox entryBox; Gtk::Label entryLabel; void init (); 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; +} + |