View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001902 | ardour | features | public | 2007-10-05 23:27 | 2007-11-05 17:59 |
Reporter | jdavisp3 | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 2.0 | ||||
Summary | 0001902: nice to have the audio import dialog keyboard-able | ||||
Description | If you already have a sound file path you can paste it's nice to be able to use the keyboard input for the new audio import dialog. | ||||
Additional Information | This is somewhat tricky, as the file chooser wants to use 'enter' to activate one of the dialog action buttons (usually 'OK'). Here is my attempt to solve this, it requires adding a 'Play' button in the action area for the enter key to default to and hooking into the 'response' callback to do our own thing (playback). I figure since most file choosers in gtk have double-click and enter do the same thing, it makes sense to have the enter key do the audition, assuming you are putting in a file and not a directory. For directories, my patch just changes the currently browsed folder for the chooser. | ||||
Tags | No tags attached. | ||||
2007-10-05 23:27
|
ardour-2.0.patch (2,148 bytes)
Index: gtk2_ardour/sfdb_ui.cc =================================================================== --- gtk2_ardour/sfdb_ui.cc (revision 2511) +++ gtk2_ardour/sfdb_ui.cc (working copy) @@ -33,6 +33,7 @@ #include <pbd/tokenizer.h> #include <pbd/enumwriter.h> +#include <gtkmm2ext/stop_signal.h> #include <gtkmm2ext/utils.h> #include <ardour/audio_library.h> @@ -446,10 +447,13 @@ found_search_btn.signal_clicked().connect(mem_fun(*this, &SoundFileBrowser::found_search_clicked)); found_entry.signal_activate().connect(mem_fun(*this, &SoundFileBrowser::found_search_clicked)); + signal_response().connect(mem_fun(*this, &SoundFileBrowser::on_response), false); + add_button (Stock::CANCEL, RESPONSE_CANCEL); + add_button (Stock::MEDIA_PLAY, 0); add_button (Stock::APPLY, RESPONSE_APPLY); add_button (Stock::OK, RESPONSE_OK); - + set_default_response(0); } SoundFileBrowser::~SoundFileBrowser () @@ -606,6 +610,31 @@ } } +void +SoundFileBrowser::on_response (int response) +{ + if (response < 0) // it is a standard gtk response + return; + + // it is the play response, we will deal with it + stop_signal(*this, "response"); + + const std::string str = Glib::filename_from_utf8(chooser.get_filename()); + + if (Glib::file_test(str, Glib::FILE_TEST_IS_DIR)) { + chooser.set_action(Gtk::FILE_CHOOSER_ACTION_SAVE); + chooser.set_current_name(""); + chooser.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN); + chooser.set_select_multiple (true); + chooser.set_current_folder(str); + } + else if (Glib::file_test(str, Glib::FILE_TEST_EXISTS)) { + chooser.set_filename(str); + preview.setup_labels(str); + chooser_file_activated(); + } +} + vector<ustring> SoundFileBrowser::get_paths () { Index: gtk2_ardour/sfdb_ui.h =================================================================== --- gtk2_ardour/sfdb_ui.h (revision 2511) +++ gtk2_ardour/sfdb_ui.h (working copy) @@ -156,6 +156,7 @@ void found_list_view_selected (); void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*); void found_search_clicked (); + void on_response (int response); void chooser_file_activated (); |
2007-11-05 17:59
|
|