tweak Prompter API to allow skipping the default "Cancel" button

This commit is contained in:
Paul Davis 2020-05-18 16:01:56 -06:00
parent 4c8f562053
commit 618c7a6bf2
2 changed files with 12 additions and 9 deletions

View File

@ -28,30 +28,33 @@
using namespace std;
using namespace ArdourWidgets;
Prompter::Prompter (Gtk::Window& parent, bool modal)
Prompter::Prompter (Gtk::Window& parent, bool modal, bool with_cancel)
: Gtk::Dialog ("", parent, modal)
, first_show (true)
, can_accept_from_entry (false)
{
init ();
init (with_cancel);
}
Prompter::Prompter (bool modal)
Prompter::Prompter (bool modal, bool with_cancel)
: Gtk::Dialog ("", modal)
, first_show (true)
, can_accept_from_entry (false)
{
init ();
init (with_cancel);
}
void
Prompter::init ()
Prompter::init (bool with_cancel)
{
set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
set_position (Gtk::WIN_POS_MOUSE);
set_name ("Prompter");
if (with_cancel) {
/* some callers need to name this button more sensibly */
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
}
/*
Alas a generic 'affirmative' button seems a bit useless sometimes.

View File

@ -38,8 +38,8 @@ namespace ArdourWidgets {
class LIBWIDGETS_API Prompter : public Gtk::Dialog
{
public:
Prompter (bool modal = false);
Prompter (Gtk::Window& parent, bool modal = false);
Prompter (bool modal = false, bool with_cancel_button = true);
Prompter (Gtk::Window& parent, bool modal = false, bool with_cancel_button = true);
~Prompter () {};
void set_prompt (std::string prompt) {
@ -68,7 +68,7 @@ private:
bool first_show;
bool can_accept_from_entry;
void init ();
void init (bool with_cancel);
void entry_activated ();
};