diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-21 21:08:24 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-21 21:08:24 +0000 |
commit | 004a49b0c7051a4d0f8972b0aff0ef8fa9cab03d (patch) | |
tree | 714a876b19460d82f5793f68bc4c3bfefb480d32 /libs | |
parent | d63c0fa328429ff0d7917fe3f4458c97063ba450 (diff) |
Gtkmm2ext::Choice now inherits from Gtk::Dialog; embed/import rate mismatch dialog no longer hangs in recursive Main::run() call
git-svn-id: svn://localhost/trunk/ardour2@414 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/choice.cc | 48 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/choice.h | 24 |
2 files changed, 18 insertions, 54 deletions
diff --git a/libs/gtkmm2ext/choice.cc b/libs/gtkmm2ext/choice.cc index 195716ada9..d1de376312 100644 --- a/libs/gtkmm2ext/choice.cc +++ b/libs/gtkmm2ext/choice.cc @@ -18,6 +18,7 @@ $Id$ */ +#include <gtkmm/label.h> #include <gtkmm2ext/choice.h> using namespace std; @@ -25,39 +26,27 @@ using namespace Gtkmm2ext; using namespace sigc; using namespace Gtk; -Choice::Choice (string prompt, - vector<string> choices) - : Gtk::Window (WINDOW_TOPLEVEL), - prompt_label (prompt) +Choice::Choice (string prompt, vector<string> choices) { int n; vector<string>::iterator i; set_position (Gtk::WIN_POS_CENTER); set_name ("ChoiceWindow"); - add (packer); - - packer.set_spacing (10); - packer.set_border_width (10); - packer.pack_start (prompt_label); - packer.pack_start (button_packer); - prompt_label.set_name ("ChoicePrompt"); + + Label* label = manage (new Label (prompt)); + label->show (); + + get_vbox()->pack_start (*label); for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) { - Button *button = manage (new Gtk::Button (*i)); - button->set_name ("ChoiceButton"); - button_packer.set_spacing (5); - button_packer.set_homogeneous (true); - button_packer.pack_start (*button, false, true); + Button* button; - button->signal_clicked().connect (bind (mem_fun (*this, &Choice::_choice_made), n)); - buttons.push_back (button); + button = add_button (*i, RESPONSE_ACCEPT); + button->signal_button_release_event().connect (bind (mem_fun (*this, &Choice::choice_made), n), false); } - signal_delete_event().connect(mem_fun(*this, &Choice::closed)); - - packer.show_all (); which_choice = -1; } @@ -72,21 +61,12 @@ Choice::~Choice () { } -void -Choice::_choice_made (int nbutton) +bool +Choice::choice_made (GdkEventButton* ev, int nbutton) { which_choice = nbutton; - choice_made (which_choice); - chosen (); -} - -gint -Choice::closed (GdkEventAny *ev) -{ - which_choice = -1; - choice_made (which_choice); - chosen (); - return TRUE; + response (RESPONSE_ACCEPT); + return true; } int diff --git a/libs/gtkmm2ext/gtkmm2ext/choice.h b/libs/gtkmm2ext/gtkmm2ext/choice.h index 4b8baede52..8dfa5043fa 100644 --- a/libs/gtkmm2ext/gtkmm2ext/choice.h +++ b/libs/gtkmm2ext/gtkmm2ext/choice.h @@ -1,42 +1,26 @@ #ifndef __pbd_gtkmm_choice_h__ #define __pbd_gtkmm_choice_h__ -#include <gtkmm.h> +#include <gtkmm/dialog.h> +#include <string> #include <vector> namespace Gtkmm2ext { -class Choice : public Gtk::Window +class Choice : public Gtk::Dialog { public: Choice (std::string prompt, std::vector<std::string> choices); virtual ~Choice (); - /* This signal will be raised when a choice - is made or the choice window is deleted. - If the choice was to cancel, or the window - was deleted, then the argument will be -1. - Otherwise, it will be choice selected - of those presented, starting at zero. - */ - - sigc::signal<void,int> choice_made; - sigc::signal<void> chosen; - int get_choice (); protected: void on_realize (); private: - Gtk::VBox packer; - Gtk::Label prompt_label; - Gtk::HBox button_packer; - std::vector<Gtk::Button*> buttons; int which_choice; - - void _choice_made (int nbutton); - gint closed (GdkEventAny *); + bool choice_made (GdkEventButton* ev, int nbutton); }; } /* namespace */ |