View Issue Details

IDProjectCategoryView StatusLast Update
0001902ardourfeaturespublic2007-11-05 17:59
Reporterjdavisp3 Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version2.0 
Summary0001902: nice to have the audio import dialog keyboard-able
DescriptionIf 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 InformationThis 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.
TagsNo tags attached.

Activities

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 ();
 	
ardour-2.0.patch (2,148 bytes)   

2007-11-05 17:59

 

import.png (72,245 bytes)   
import.png (72,245 bytes)   

Issue History

Date Modified Username Field Change
2007-10-05 23:27 jdavisp3 New Issue
2007-10-05 23:27 jdavisp3 File Added: ardour-2.0.patch
2007-11-05 17:59 jdavisp3 File Added: import.png