Use SSE/veclib/whatever for AudioBuffer::accumulate_from
[ardour.git] / libs / gtkmm2ext / prompter.cc
index 8f78d3179dba70bd349d6c491e9715c09272c013..0ff97103380becd0b74a9191a55425b71fc6bbb5 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <string>
 
+#include <pbd/whitespace.h>
+
 #include <gtkmm/stock.h>
 #include <gtkmm2ext/prompter.h>
 
@@ -43,14 +45,20 @@ Prompter::Prompter (bool modal)
 void
 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::OK, 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);
        entryLabel.set_name ("PrompterLabel");
 
@@ -62,7 +70,7 @@ Prompter::init ()
 
        get_vbox()->pack_start (entryBox);
        show_all_children();
-
+       entry.signal_changed().connect (mem_fun (*this, &Prompter::on_entry_changed));
        entry.signal_activate().connect (bind (mem_fun (*this, &Prompter::response), Gtk::RESPONSE_ACCEPT));
 }      
 
@@ -74,8 +82,28 @@ Prompter::change_labels (string okstr, string cancelstr)
 }
 
 void
-Prompter::get_result (string &str)
-
+Prompter::get_result (string &str, bool strip)
 {
        str = entry.get_text ();
+       if (strip) {
+               PBD::strip_whitespace_edges (str);
+       }
+}
+
+void
+Prompter::on_entry_changed ()
+{
+       /* 
+          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);
+       }
 }