mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Extend LV2UI-Request-Parameter File/Path GUI
This is a bit of a playground implementation, the various `#if 0` code-blocks should be removed.
This commit is contained in:
parent
f795462100
commit
e297951b30
2 changed files with 57 additions and 16 deletions
|
|
@ -17,6 +17,8 @@
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include "ardour/lv2_plugin.h"
|
#include "ardour/lv2_plugin.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
|
|
@ -114,6 +116,23 @@ LV2PluginUI::touch(void* controller,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LV2PluginUI::set_path_property (int response,
|
||||||
|
const ParameterDescriptor& desc,
|
||||||
|
Gtk::FileChooserDialog* widget)
|
||||||
|
{
|
||||||
|
if (response == Gtk::RESPONSE_ACCEPT) {
|
||||||
|
plugin->set_property (desc.key, Variant (Variant::PATH, widget->get_filename()));
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
widget->hide ();
|
||||||
|
delete_when_idle (widget);
|
||||||
|
#else
|
||||||
|
delete widget;
|
||||||
|
#endif
|
||||||
|
active_parameter_requests.erase (desc.key);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
LV2PluginUI::request_parameter (void* handle, LV2_URID key)
|
LV2PluginUI::request_parameter (void* handle, LV2_URID key)
|
||||||
{
|
{
|
||||||
|
|
@ -122,35 +141,53 @@ LV2PluginUI::request_parameter (void* handle, LV2_URID key)
|
||||||
/* This will return `PropertyDescriptors nothing` when not found */
|
/* This will return `PropertyDescriptors nothing` when not found */
|
||||||
const ParameterDescriptor& desc (me->_lv2->get_property_descriptor(key));
|
const ParameterDescriptor& desc (me->_lv2->get_property_descriptor(key));
|
||||||
if (desc.datatype != Variant::PATH) {
|
if (desc.datatype != Variant::PATH) {
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check if window for current URID already exists -> return -1;
|
#if 0 // MODAL, blocking
|
||||||
// Create and show window, subscribe to file-selected signal
|
|
||||||
// then return 0; don't block here.
|
|
||||||
|
|
||||||
Gtk::FileChooserDialog lv2ui_file_dialog (desc.label, FILE_CHOOSER_ACTION_OPEN);
|
Gtk::FileChooserDialog* lv2ui_file_dialog (desc.label, FILE_CHOOSER_ACTION_OPEN);
|
||||||
Gtkmm2ext::add_volume_shortcuts (lv2ui_file_dialog);
|
Gtkmm2ext::add_volume_shortcuts (lv2ui_file_dialog);
|
||||||
|
lv2ui_file_dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
|
lv2ui_file_dialog.add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
|
||||||
|
lv2ui_file_dialog.set_default_response(Gtk::RESPONSE_ACCEPT);
|
||||||
|
if (_file_dialog.run()= Gtk::RESPONSE_ACCEPT) {
|
||||||
|
me->plugin->set_property (desc.key, Variant(Variant::PATH, lv2ui_file_dialog.get_filename()));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* LV2Plugin does not currently save property values and only
|
#else
|
||||||
* emits a PropertyChanged(urid, Variant) signal
|
|
||||||
*/
|
|
||||||
//lv2ui_file_dialog.set_current_folder (TODO)
|
|
||||||
|
|
||||||
#if 0 // TODO mime-type,
|
if (me->active_parameter_requests.find (key) != me->active_parameter_requests.end()) {
|
||||||
|
return 0; /* already showing dialog */
|
||||||
|
}
|
||||||
|
me->active_parameter_requests.insert (key);
|
||||||
|
|
||||||
|
Gtk::FileChooserDialog* lv2ui_file_dialog = new Gtk::FileChooserDialog(desc.label, FILE_CHOOSER_ACTION_OPEN);
|
||||||
|
Gtkmm2ext::add_volume_shortcuts (*lv2ui_file_dialog);
|
||||||
|
lv2ui_file_dialog->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
|
lv2ui_file_dialog->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
|
||||||
|
lv2ui_file_dialog->set_default_response(Gtk::RESPONSE_ACCEPT);
|
||||||
|
|
||||||
|
/* this assumes announce_property_values() was called, or
|
||||||
|
* the plugin has previously sent a patch:Set */
|
||||||
|
const Variant& value = me->_lv2->get_property_value (desc.key);
|
||||||
|
if (value.type() == Variant::PATH) {
|
||||||
|
lv2ui_file_dialog->set_filename (value.get_path());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0 // TODO mime-type, file-extension filter, get from LV2 Parameter Property
|
||||||
FileFilter file_ext_filter;
|
FileFilter file_ext_filter;
|
||||||
file_ext_filter.add_pattern ("*.foo");
|
file_ext_filter.add_pattern ("*.foo");
|
||||||
file_ext_filter.set_name ("Foo File");
|
file_ext_filter.set_name ("Foo File");
|
||||||
lv2ui_file_dialog.add_filter (file_ext_filter);
|
lv2ui_file_dialog.add_filter (file_ext_filter);
|
||||||
#endif
|
#endif
|
||||||
int response = lv2ui_file_dialog.run();
|
|
||||||
lv2ui_file_dialog.hide ();
|
|
||||||
|
|
||||||
if (response == Gtk::RESPONSE_OK) {
|
|
||||||
me->plugin->set_property (desc.key, Variant(Variant::PATH, lv2ui_file_dialog.get_filename()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
lv2ui_file_dialog->signal_response().connect (sigc::bind (sigc::mem_fun (*me, &LV2PluginUI::set_path_property), desc, lv2ui_file_dialog));
|
||||||
|
lv2ui_file_dialog->present();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,10 @@ private:
|
||||||
bool grabbed);
|
bool grabbed);
|
||||||
|
|
||||||
static uint32_t request_parameter (void* handle, LV2_URID key);
|
static uint32_t request_parameter (void* handle, LV2_URID key);
|
||||||
|
void set_path_property (int,
|
||||||
|
const ARDOUR::ParameterDescriptor&,
|
||||||
|
Gtk::FileChooserDialog*);
|
||||||
|
std::set<uint32_t> active_parameter_requests;
|
||||||
|
|
||||||
void update_timeout();
|
void update_timeout();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue