diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-22 17:03:00 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-22 17:03:00 +0000 |
commit | 3aa346b253d515c3d0715ec5e0fa8b6ad477c4e5 (patch) | |
tree | a41d4380ad270324a2d05cbbab0d1e57dce2bdfe /libs | |
parent | 004a49b0c7051a4d0f8972b0aff0ef8fa9cab03d (diff) |
significant changes in code to handle import/embedding - much cleaner and less code, plus the import progress bar now works; unify response handling for Gtkmm2ext::Choice
git-svn-id: svn://localhost/trunk/ardour2@415 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session.h | 18 | ||||
-rw-r--r-- | libs/ardour/import.cc | 9 | ||||
-rw-r--r-- | libs/gtkmm2ext/choice.cc | 34 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/choice.h | 8 | ||||
-rw-r--r-- | libs/pbd3/pthread_utils.cc | 2 |
5 files changed, 28 insertions, 43 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 24f15e97f5..a422e52d3d 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -640,13 +640,17 @@ class Session : public sigc::trackable, public Stateful /* source management */ struct import_status : public InterThreadInfo { - string doing_what; - - /* control info */ - bool multichan; - bool sample_convert; - volatile bool freeze; - string pathname; + string doing_what; + + /* control info */ + bool multichan; + bool sample_convert; + volatile bool freeze; + string pathname; + + /* result */ + std::vector<AudioRegion*> new_regions; + }; int import_audiofile (import_status&); diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index f5884a1c1d..aa7b902501 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -61,11 +61,12 @@ Session::import_audiofile (import_status& status) jack_nframes_t so_far; char buf[PATH_MAX+1]; int ret = -1; - vector<AudioRegion *> new_regions; vector<string> new_paths; struct tm* now; string tmp_convert_file; + status.new_regions.clear (); + if ((in = sf_open (status.pathname.c_str(), SFM_READ, &info)) == 0) { error << string_compose(_("Import: cannot open input sound file \"%1\""), status.pathname) << endmsg; return -1; @@ -214,7 +215,7 @@ Session::import_audiofile (import_status& status) AudioRegion *r = new AudioRegion (sources, 0, newfiles[0]->length(), region_name_from_path (PBD::basename(basepath)), 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile)); - new_regions.push_back (r); + status.new_regions.push_back (r); } else { for (n = 0; n < nfiles && !status.cancel; ++n) { @@ -230,7 +231,7 @@ Session::import_audiofile (import_status& status) AudioRegion *r = new AudioRegion (*newfiles[n], 0, newfiles[n]->length(), region_name_from_path (PBD::basename (newfiles[n]->name())), 0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile | AudioRegion::Import)); - new_regions.push_back (r); + status.new_regions.push_back (r); } } @@ -259,7 +260,7 @@ Session::import_audiofile (import_status& status) } if (status.cancel) { - for (vector<AudioRegion *>::iterator i = new_regions.begin(); i != new_regions.end(); ++i) { + for (vector<AudioRegion *>::iterator i = status.new_regions.begin(); i != status.new_regions.end(); ++i) { delete *i; } diff --git a/libs/gtkmm2ext/choice.cc b/libs/gtkmm2ext/choice.cc index d1de376312..d00d75d38b 100644 --- a/libs/gtkmm2ext/choice.cc +++ b/libs/gtkmm2ext/choice.cc @@ -26,28 +26,30 @@ using namespace Gtkmm2ext; using namespace sigc; using namespace Gtk; -Choice::Choice (string prompt, vector<string> choices) +Choice::Choice (string prompt, vector<string> choices, bool center) { int n; vector<string>::iterator i; + + if (center) { + set_position (Gtk::WIN_POS_CENTER); + } else { + set_position (Gtk::WIN_POS_MOUSE); + } - set_position (Gtk::WIN_POS_CENTER); set_name ("ChoiceWindow"); Label* label = manage (new Label (prompt)); label->show (); + get_vbox()->set_border_width (12); get_vbox()->pack_start (*label); - for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) { + set_has_separator (false); - Button* button; - - button = add_button (*i, RESPONSE_ACCEPT); - button->signal_button_release_event().connect (bind (mem_fun (*this, &Choice::choice_made), n), false); + for (n = 0, i = choices.begin(); i != choices.end(); ++i, ++n) { + add_button (*i, n); } - - which_choice = -1; } void @@ -60,17 +62,3 @@ Choice::on_realize () Choice::~Choice () { } - -bool -Choice::choice_made (GdkEventButton* ev, int nbutton) -{ - which_choice = nbutton; - response (RESPONSE_ACCEPT); - return true; -} - -int -Choice::get_choice () -{ - return which_choice; -} diff --git a/libs/gtkmm2ext/gtkmm2ext/choice.h b/libs/gtkmm2ext/gtkmm2ext/choice.h index 8dfa5043fa..0fa466fbcc 100644 --- a/libs/gtkmm2ext/gtkmm2ext/choice.h +++ b/libs/gtkmm2ext/gtkmm2ext/choice.h @@ -10,17 +10,11 @@ namespace Gtkmm2ext { class Choice : public Gtk::Dialog { public: - Choice (std::string prompt, std::vector<std::string> choices); + Choice (std::string prompt, std::vector<std::string> choices, bool center = true); virtual ~Choice (); - int get_choice (); - protected: void on_realize (); - - private: - int which_choice; - bool choice_made (GdkEventButton* ev, int nbutton); }; } /* namespace */ diff --git a/libs/pbd3/pthread_utils.cc b/libs/pbd3/pthread_utils.cc index 1fc9227ba5..88e9aef195 100644 --- a/libs/pbd3/pthread_utils.cc +++ b/libs/pbd3/pthread_utils.cc @@ -26,8 +26,6 @@ #include <pbd/pthread_utils.h> using std::string; -using std::cerr; -using std::endl; typedef std::map<string,pthread_t> ThreadMap; static ThreadMap all_threads; |