From fe83d9b77e0aff0af45d8c9ef4f1d8187b8f600e Mon Sep 17 00:00:00 2001 From: Taybin Rutkin Date: Thu, 13 Oct 2005 03:48:57 +0000 Subject: [PATCH] sfdb almost done. git-svn-id: svn://localhost/trunk/ardour2@60 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/add_route_dialog.cc | 2 +- gtk2_ardour/ardour_ui.h | 5 +++- gtk2_ardour/ardour_ui_dialogs.cc | 22 +++++++++++--- gtk2_ardour/ardour_ui_ed.cc | 1 + gtk2_ardour/editor_ops.cc | 24 +++++++-------- gtk2_ardour/option_editor.cc | 16 ++++------ gtk2_ardour/sfdb_ui.cc | 50 ++++++++++++++++++++++++++++++++ gtk2_ardour/sfdb_ui.h | 35 ++++++++++++---------- 8 files changed, 110 insertions(+), 45 deletions(-) diff --git a/gtk2_ardour/add_route_dialog.cc b/gtk2_ardour/add_route_dialog.cc index f1ec91f636..b70c76b3ca 100644 --- a/gtk2_ardour/add_route_dialog.cc +++ b/gtk2_ardour/add_route_dialog.cc @@ -112,7 +112,7 @@ AddRouteDialog::AddRouteDialog () add (*vb2); - // delete_event.connect (mem_fun(*this, &ArdourDialog::wm_close_event)); + // signal_delete_event().connect (mem_fun(*this, &ArdourDialog::wm_close_event)); ok_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 0)); cancel_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 1)); } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 0bfc5cc7ea..c835303de7 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -502,7 +502,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI Gtk::CheckMenuItem *locations_dialog_check; Gtk::CheckMenuItem *big_clock_check; Gtk::CheckMenuItem *tempo_editor_check; -// Gtk::CheckMenuItem *sfdb_check; + Gtk::CheckMenuItem *sfdb_check; Gtk::CheckMenuItem *options_window_check; /* */ @@ -672,6 +672,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI AddRouteDialog *add_route_dialog; void add_route_dialog_done (int status); + + /* SoundFile Browser */ + void toggle_sound_file_browser (); /* Keyboard Handling */ diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index 0babbec25b..0af47c0c19 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -26,13 +26,14 @@ #include #include "ardour_ui.h" -#include "mixer_ui.h" -#include "meter_bridge.h" #include "connection_editor.h" -#include "public_editor.h" -#include "option_editor.h" #include "location_ui.h" +#include "meter_bridge.h" +#include "mixer_ui.h" +#include "option_editor.h" +#include "public_editor.h" #include "route_params_ui.h" +#include "sfdb_ui.h" #include "i18n.h" @@ -416,3 +417,16 @@ ARDOUR_UI::route_params_hiding () { route_params_check->set_active (false); } + +void +ARDOUR_UI::toggle_sound_file_browser () +{ + if (sfdb_check->get_active()) { + SoundFileBrowser sfdb(_("Sound File Browser")); + + sfdb_check->signal_toggled().connect (bind (mem_fun (sfdb, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL)); + sfdb.run(); + sfdb_check->set_active(false); + } +} + diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index f801c1f93b..aa162d1d92 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -148,6 +148,7 @@ ARDOUR_UI::install_actions () register_action (common_actions, X_("GotoEditor"), _("Editor"), mem_fun(*this, &ARDOUR_UI::goto_editor_window)); register_action (common_actions, X_("GotoMixer"), _("Mixer"), mem_fun(*this, &ARDOUR_UI::goto_mixer_window)); + register_toggle_action (common_actions, X_("ToggleSoundFileBrowser"), _("Sound File Browser"), mem_fun(*this, &ARDOUR_UI::toggle_sound_file_browser)); register_toggle_action (common_actions, X_("ToggleOptionsEditor"), _("Options Editor"), mem_fun(*this, &ARDOUR_UI::toggle_options_window)); register_toggle_action (common_actions, X_("ToggleAudioLibrary"), _("Audio Library"), mem_fun(*this, &ARDOUR_UI::toggle_sfdb_window)); act = register_toggle_action (common_actions, X_("ToggleInspector"), _("Track/Bus Inspector"), mem_fun(*this, &ARDOUR_UI::toggle_route_params_window)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 30b25c55ed..e7c81e694e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1899,13 +1899,10 @@ Editor::import_audio (bool as_tracks) str = _("Import selected to region list"); } - SoundFileChooser sfdb (str, true, true); + SoundFileOmega sfdb (str); + sfdb.Imported.connect (bind (mem_fun (*this, &Editor::do_import), as_tracks)); - int result = sfdb.run(); - - if (result == Gtk::RESULT_ACCEPTED) { - do_import(sfdb.get_filenames, sfdb.get_split(), as_tracks); - } + sfdb.run(); } void @@ -2033,9 +2030,10 @@ Editor::embed_audio () return; } - SoundFileSelector sfdb (_("Add to External Region list"), true, true); + SoundFileOmega sfdb (_("Add to External Region list")); + sfdb.Embedded.connect (mem_fun (*this, &Editor::do_embed_sndfiles)); - int result = sfdb.run (); + sfdb.run (); } void @@ -2158,13 +2156,13 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check void Editor::insert_sndfile (bool as_tracks) { - SoundFileSelector& sfdb (ARDOUR_UI::instance()->get_sfdb_window()); +// SoundFileSelector& sfdb (ARDOUR_UI::instance()->get_sfdb_window()); sigc::connection c; string str; if (as_tracks) { - c = sfdb.Action.connect (mem_fun(*this, &Editor::insert_paths_as_new_tracks)); +// c = sfdb.Action.connect (mem_fun(*this, &Editor::insert_paths_as_new_tracks)); str = _("Insert selected as new tracks"); } else { @@ -2179,12 +2177,12 @@ Editor::insert_sndfile (bool as_tracks) return; } - c = sfdb.Action.connect (bind (mem_fun(*this, &Editor::do_insert_sndfile), pos)); +// c = sfdb.Action.connect (bind (mem_fun(*this, &Editor::do_insert_sndfile), pos)); str = _("Insert selected"); } - sfdb.run (str, false); - c.disconnect (); +// sfdb.run (str, false); +// c.disconnect (); } void diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 92719b9803..cb4488fe03 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -1291,15 +1291,13 @@ OptionEditor::raid_path_changed () void OptionEditor::click_browse_clicked () { - SoundFileChooser sfdb (_("Choose Click"), false, false); + SoundFileChooser sfdb (_("Choose Click")); int result = sfdb.run (); - if (result != Gtk::RESPONSE_ACCEPT) { - return; + if (result == Gtk::RESPONSE_OK) { + click_chosen(sfdb.get_filename()); } - - click_chosen(sfdb.get_filename()); } void @@ -1312,15 +1310,13 @@ OptionEditor::click_chosen (string path) void OptionEditor::click_emphasis_browse_clicked () { - SoundFileChooser sfdb (_("Click Emphasis"), false, false); + SoundFileChooser sfdb (_("Choose Click Emphasis")); int result = sfdb.run (); - if (result != Gtk::RESPONSE_ACCEPT) { - return; + if (result == Gtk::RESPONSE_OK) { + click_emphasis_chosen (sfdb.get_filename()); } - - click_emphasis_chosen (sfdb.get_filename()); } void diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index fcb6d3d8e4..adf0167095 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -1,4 +1,54 @@ +#include +#include + +#include + #include "sfdb_ui.h" #include "i18n.h" +SoundFileBrowser::SoundFileBrowser (std::string title) + : + Gtk::Dialog(title, false), + chooser(Gtk::FILE_CHOOSER_ACTION_OPEN) +{ + get_vbox()->pack_start(chooser); +} + +SoundFileChooser::SoundFileChooser (std::string title) + : + SoundFileBrowser(title) +{ + add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); +} + +SoundFileOmega::SoundFileOmega (std::string title) + : + SoundFileBrowser(title), + embed_btn (_("Embed")), + import_btn (_("Import")), + split_check (_("Split Channels")) +{ + get_action_area()->pack_start(embed_btn); + get_action_area()->pack_start(import_btn); + add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); + + chooser.set_extra_widget(split_check); + + embed_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::embed_clicked)); + import_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::import_clicked)); +} + +void +SoundFileOmega::embed_clicked () +{ + Embedded (chooser.get_filenames(), split_check.get_active()); +} + +void +SoundFileOmega::import_clicked () +{ + Imported (chooser.get_filenames(), split_check.get_active()); +} + diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h index fda3c1d94e..26ce3c15b3 100644 --- a/gtk2_ardour/sfdb_ui.h +++ b/gtk2_ardour/sfdb_ui.h @@ -4,7 +4,11 @@ #include #include +#include + +#include #include +#include #include #include @@ -12,38 +16,37 @@ class SoundFileBrowser : public Gtk::Dialog { public: SoundFileBrowser (std::string title); - virtual ~SoundFileBrowser (); + virtual ~SoundFileBrowser () {} protected: - Gtk::FileChooserWidget* chooser; - - Gtk::Button* ok_btn; + Gtk::FileChooserWidget chooser; }; class SoundFileChooser : public SoundFileBrowser { public: SoundFileChooser (std::string title); - virtual ~SoundFileChooser (); - - std::string get_filename (); + virtual ~SoundFileChooser () {}; - protected: - Gtk::Button* open_btn; + std::string get_filename () {return chooser.get_filename();}; }; -class SoundFileOmega : public SoundFileChooser +class SoundFileOmega : public SoundFileBrowser { public: SoundFileOmega (std::string title); - virtual ~SoundFileOmega (); + virtual ~SoundFileOmega () {}; - std::vector get_filenames(); - bool get_split(); + sigc::signal, bool> Embedded; + sigc::signal, bool> Imported; protected: - Gtk::Button* insert_btn; - Gtk::Button* import_btn; -} + Gtk::Button embed_btn; + Gtk::Button import_btn; + Gtk::CheckButton split_check; + + void embed_clicked (); + void import_clicked (); +}; #endif // __ardour_sfdb_ui_h__ -- 2.30.2