From 618c7a6bf26949461039f8b379f45ae2a9491668 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 May 2020 16:01:56 -0600 Subject: tweak Prompter API to allow skipping the default "Cancel" button --- libs/widgets/prompter.cc | 15 +++++++++------ libs/widgets/widgets/prompter.h | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libs/widgets/prompter.cc b/libs/widgets/prompter.cc index de18be29df..9f2df26b5e 100644 --- a/libs/widgets/prompter.cc +++ b/libs/widgets/prompter.cc @@ -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"); - add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + 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. diff --git a/libs/widgets/widgets/prompter.h b/libs/widgets/widgets/prompter.h index afe6733d1b..94e0ad65cc 100644 --- a/libs/widgets/widgets/prompter.h +++ b/libs/widgets/widgets/prompter.h @@ -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 (); }; -- cgit v1.2.3