save trigger custom MIDI learn as a binding map
This commit is contained in:
parent
10e004f0ec
commit
8362e865ee
@ -16,6 +16,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <gtkmm/alignment.h>
|
||||
#include <gtkmm/filechooserdialog.h>
|
||||
#include <gtkmm/menu.h>
|
||||
@ -401,11 +403,60 @@ TriggerUI::context_menu ()
|
||||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("MIDI Learn"), sigc::mem_fun (*this, &TriggerUI::trigger_midi_learn)));
|
||||
items.push_back (MenuElem (_("MIDI un-Learn"), sigc::mem_fun (*this, &TriggerUI::trigger_midi_unlearn)));
|
||||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("Save all MIDI Learn settings"), sigc::mem_fun (*this, &TriggerUI::save_midi_learn)));
|
||||
|
||||
|
||||
_context_menu->popup (3, gtk_get_current_event_time ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::save_midi_learn ()
|
||||
{
|
||||
Gtk::FileChooserDialog d (_("Choose filename"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
std::string midi_maps = Glib::build_filename (user_config_directory(), "midi_maps");
|
||||
|
||||
if (!Glib::file_test (midi_maps, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
|
||||
::g_mkdir (midi_maps.c_str(), 0755);
|
||||
}
|
||||
|
||||
d.set_current_folder (midi_maps);
|
||||
d.present ();
|
||||
|
||||
d.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
d.add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
||||
|
||||
while (true) {
|
||||
int result = d.run ();
|
||||
|
||||
if (result == Gtk::RESPONSE_OK) {
|
||||
|
||||
std::string filename = d.get_filename ();
|
||||
|
||||
if (filename.find (".midi_map") == std::string::npos) {
|
||||
filename += X_(".midi_map");
|
||||
}
|
||||
|
||||
if (Glib::file_test (filename, Glib::FILE_TEST_EXISTS)) {
|
||||
Gtk::MessageDialog msg (string_compose (_("%1 already exists.\n"
|
||||
"Please select a different filename"), filename));
|
||||
msg.run ();
|
||||
msg.set_keep_above (true);
|
||||
continue;
|
||||
}
|
||||
|
||||
TriggerBox::dump_custom_midi_bindings (filename);
|
||||
break;
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::trigger_midi_learn ()
|
||||
{
|
||||
|
@ -91,6 +91,8 @@ public:
|
||||
void trigger_midi_learn ();
|
||||
void trigger_midi_unlearn ();
|
||||
|
||||
void save_midi_learn ();
|
||||
|
||||
private:
|
||||
void trigger_changed (PBD::PropertyChange const& ); //calls on_trigger_changed to subclasses
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user