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
This commit is contained in:
parent
d63c0fa328
commit
004a49b0c7
|
@ -308,7 +308,6 @@
|
||||||
<menuitem action='SortBySourceFilesystem'/>
|
<menuitem action='SortBySourceFilesystem'/>
|
||||||
</menu>
|
</menu>
|
||||||
<separator/>
|
<separator/>
|
||||||
<menuitem action='rlEmbedAudio'/>
|
<menuitem action='addExternalRegion'/>
|
||||||
<menuitem action='rlImportAudio'/>
|
|
||||||
</popup>
|
</popup>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -340,9 +340,7 @@ Editor::register_actions ()
|
||||||
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"), _("By Source Filesystem"),
|
ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"), _("By Source Filesystem"),
|
||||||
bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
|
bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
|
||||||
|
|
||||||
act = ActionManager::register_action (rl_actions, X_("rlEmbedAudio"), _("Embed audio (link)"), mem_fun(*this, &Editor::embed_audio));
|
act = ActionManager::register_action (rl_actions, X_("addExternalAudio"), _("Embed audio (link)"), mem_fun(*this, &Editor::embed_audio));
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
|
||||||
act = ActionManager::register_action (rl_actions, X_("rlImportAudio"), _("Embed audio (link)"), bind (mem_fun(*this, &Editor::import_audio), false));
|
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
|
|
||||||
ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
|
ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
|
||||||
|
|
|
@ -199,10 +199,9 @@ Do you really want to destroy %1 ?"),
|
||||||
|
|
||||||
Gtkmm2ext::Choice prompter (prompt, choices);
|
Gtkmm2ext::Choice prompter (prompt, choices);
|
||||||
|
|
||||||
prompter.chosen.connect (ptr_fun (Main::quit));
|
if (prompter.run () != RESPONSE_ACCEPT) {
|
||||||
prompter.show_all ();
|
return;
|
||||||
|
}
|
||||||
Main::run ();
|
|
||||||
|
|
||||||
if (prompter.get_choice() != 0) {
|
if (prompter.get_choice() != 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -2128,10 +2127,16 @@ Editor::reject_because_rate_differs (const string & path, SoundFileInfo& finfo,
|
||||||
string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
|
string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
|
||||||
choices);
|
choices);
|
||||||
|
|
||||||
rate_choice.chosen.connect (ptr_fun (Main::quit));
|
int response = rate_choice.run();
|
||||||
rate_choice.show_all ();
|
|
||||||
|
|
||||||
Main::run ();
|
switch (response) {
|
||||||
|
case RESPONSE_ACCEPT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* stop all that might come after this */
|
||||||
|
return -2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (rate_choice.get_choice()) {
|
switch (rate_choice.get_choice()) {
|
||||||
case 0: /* do it anyway */
|
case 0: /* do it anyway */
|
||||||
|
@ -3546,13 +3551,11 @@ Editor::remove_last_capture ()
|
||||||
choices.push_back (_("No, do nothing."));
|
choices.push_back (_("No, do nothing."));
|
||||||
|
|
||||||
Gtkmm2ext::Choice prompter (prompt, choices);
|
Gtkmm2ext::Choice prompter (prompt, choices);
|
||||||
prompter.chosen.connect (ptr_fun (Main::quit));
|
|
||||||
prompter.show_all ();
|
|
||||||
|
|
||||||
Main::run ();
|
|
||||||
|
|
||||||
if (prompter.get_choice() == 0) {
|
if (prompter.run () == RESPONSE_ACCEPT) {
|
||||||
session->remove_last_capture ();
|
if (prompter.get_choice() == 0) {
|
||||||
|
session->remove_last_capture ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -900,17 +900,13 @@ RedirectBox::clear_redirects()
|
||||||
|
|
||||||
Gtkmm2ext::Choice prompter (prompt, choices);
|
Gtkmm2ext::Choice prompter (prompt, choices);
|
||||||
|
|
||||||
prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
|
if (prompter.run () == RESPONSE_ACCEPT) {
|
||||||
prompter.show_all ();
|
if (prompter.get_choice() == 0) {
|
||||||
|
_route.clear_redirects (this);
|
||||||
Gtk::Main::run ();
|
}
|
||||||
|
|
||||||
if (prompter.get_choice() == 0) {
|
|
||||||
_route.clear_redirects (this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RedirectBox::edit_redirect (Redirect* redirect)
|
RedirectBox::edit_redirect (Redirect* redirect)
|
||||||
{
|
{
|
||||||
|
|
|
@ -703,13 +703,12 @@ RouteUI::remove_this_route ()
|
||||||
|
|
||||||
Choice prompter (prompt, choices);
|
Choice prompter (prompt, choices);
|
||||||
|
|
||||||
prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
|
|
||||||
prompter.show_all ();
|
prompter.show_all ();
|
||||||
|
|
||||||
Gtk::Main::run ();
|
if (prompter.run () == RESPONSE_ACCEPT) {
|
||||||
|
if (prompter.get_choice() == 0) {
|
||||||
if (prompter.get_choice() == 0) {
|
Glib::signal_idle().connect (bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
|
||||||
Glib::signal_idle().connect (bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,18 +279,14 @@ VisualTimeAxis::remove_this_time_axis(void* src)
|
||||||
|
|
||||||
Gtkmm2ext::Choice prompter (prompt, choices);
|
Gtkmm2ext::Choice prompter (prompt, choices);
|
||||||
|
|
||||||
prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
|
if (prompter.run () == RESPONSE_ACCEPT) {
|
||||||
prompter.show_all ();
|
if (prompter.get_choice() == 0) {
|
||||||
|
/*
|
||||||
Gtk::Main::run ();
|
defer to idle loop, otherwise we'll delete this object
|
||||||
|
while we're still inside this function ...
|
||||||
if (prompter.get_choice() == 0)
|
*/
|
||||||
{
|
Glib::signal_idle().connect(bind(sigc::ptr_fun(&VisualTimeAxis::idle_remove_this_time_axis), this, src));
|
||||||
/*
|
}
|
||||||
defer to idle loop, otherwise we'll delete this object
|
|
||||||
while we're still inside this function ...
|
|
||||||
*/
|
|
||||||
Glib::signal_idle().connect(bind(sigc::ptr_fun(&VisualTimeAxis::idle_remove_this_time_axis), this, src));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <gtkmm/label.h>
|
||||||
#include <gtkmm2ext/choice.h>
|
#include <gtkmm2ext/choice.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -25,39 +26,27 @@ using namespace Gtkmm2ext;
|
||||||
using namespace sigc;
|
using namespace sigc;
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
|
|
||||||
Choice::Choice (string prompt,
|
Choice::Choice (string prompt, vector<string> choices)
|
||||||
vector<string> choices)
|
|
||||||
: Gtk::Window (WINDOW_TOPLEVEL),
|
|
||||||
prompt_label (prompt)
|
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
vector<string>::iterator i;
|
vector<string>::iterator i;
|
||||||
|
|
||||||
set_position (Gtk::WIN_POS_CENTER);
|
set_position (Gtk::WIN_POS_CENTER);
|
||||||
set_name ("ChoiceWindow");
|
set_name ("ChoiceWindow");
|
||||||
add (packer);
|
|
||||||
|
Label* label = manage (new Label (prompt));
|
||||||
packer.set_spacing (10);
|
label->show ();
|
||||||
packer.set_border_width (10);
|
|
||||||
packer.pack_start (prompt_label);
|
get_vbox()->pack_start (*label);
|
||||||
packer.pack_start (button_packer);
|
|
||||||
prompt_label.set_name ("ChoicePrompt");
|
|
||||||
|
|
||||||
for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) {
|
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* button;
|
||||||
button_packer.set_homogeneous (true);
|
|
||||||
button_packer.pack_start (*button, false, true);
|
|
||||||
|
|
||||||
button->signal_clicked().connect (bind (mem_fun (*this, &Choice::_choice_made), n));
|
button = add_button (*i, RESPONSE_ACCEPT);
|
||||||
buttons.push_back (button);
|
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;
|
which_choice = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,21 +61,12 @@ Choice::~Choice ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Choice::_choice_made (int nbutton)
|
Choice::choice_made (GdkEventButton* ev, int nbutton)
|
||||||
{
|
{
|
||||||
which_choice = nbutton;
|
which_choice = nbutton;
|
||||||
choice_made (which_choice);
|
response (RESPONSE_ACCEPT);
|
||||||
chosen ();
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
Choice::closed (GdkEventAny *ev)
|
|
||||||
{
|
|
||||||
which_choice = -1;
|
|
||||||
choice_made (which_choice);
|
|
||||||
chosen ();
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -1,42 +1,26 @@
|
||||||
#ifndef __pbd_gtkmm_choice_h__
|
#ifndef __pbd_gtkmm_choice_h__
|
||||||
#define __pbd_gtkmm_choice_h__
|
#define __pbd_gtkmm_choice_h__
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm/dialog.h>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
class Choice : public Gtk::Window
|
class Choice : public Gtk::Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Choice (std::string prompt, std::vector<std::string> choices);
|
Choice (std::string prompt, std::vector<std::string> choices);
|
||||||
virtual ~Choice ();
|
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 ();
|
int get_choice ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_realize ();
|
void on_realize ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::VBox packer;
|
|
||||||
Gtk::Label prompt_label;
|
|
||||||
Gtk::HBox button_packer;
|
|
||||||
std::vector<Gtk::Button*> buttons;
|
|
||||||
int which_choice;
|
int which_choice;
|
||||||
|
bool choice_made (GdkEventButton* ev, int nbutton);
|
||||||
void _choice_made (int nbutton);
|
|
||||||
gint closed (GdkEventAny *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user