+#endif
+}
+
+void KeyFrameThread::save_preset(const char *title, int is_factory)
+{
+ get_gui()->unlock_window();
+ mwindow->gui->lock_window("KeyFrameThread::save_preset");
+
+// Test EDL for plugin existence
+ if( !mwindow->edl->tracks->plugin_exists(plugin) ) {
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::save_preset 2");
+ return;
+ }
+
+// Get current plugin keyframe
+ EDL *edl = mwindow->edl;
+ Track *track = plugin->track;
+ KeyFrame *keyframe = plugin->get_prev_keyframe(
+ track->to_units(edl->local_session->get_selectionstart(1), 0),
+ PLAY_FORWARD);
+
+// Send to database
+ presets_db->save_preset(plugin_title, title, keyframe->get_data());
+
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::save_preset 2");
+
+// Update list
+ calculate_preset_list();
+ ((KeyFrameWindow*)get_gui())->preset_list->update(presets_data,
+ 0, 0, 1);
+}
+
+void KeyFrameThread::delete_preset(const char *title, int is_factory)
+{
+ get_gui()->unlock_window();
+ mwindow->gui->lock_window("KeyFrameThread::save_preset");
+
+// Test EDL for plugin existence
+ if( !mwindow->edl->tracks->plugin_exists(plugin) ) {
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::delete_preset 1");
+ return;
+ }
+
+ presets_db->delete_preset(plugin_title, title, is_factory);
+
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::delete_preset 2");
+
+// Update list
+ calculate_preset_list();
+ ((KeyFrameWindow*)get_gui())->preset_list->update(presets_data,
+ 0, 0, 1);
+}
+
+
+void KeyFrameThread::apply_preset(const char *title, int is_factory)
+{
+ if( presets_db->preset_exists(plugin_title, title, is_factory) ) {
+ get_gui()->unlock_window();
+ mwindow->gui->lock_window("KeyFrameThread::apply_preset");
+
+// Test EDL for plugin existence
+ if( !mwindow->edl->tracks->plugin_exists(plugin) ) {
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::apply_preset 1");
+ return;
+ }
+
+ mwindow->undo->update_undo_before();
+
+#ifdef USE_KEYFRAME_SPANNING
+ KeyFrame keyframe;
+ presets_db->load_preset(plugin_title, title, &keyframe, is_factory);
+ plugin->keyframes->update_parameter(&keyframe);
+#else
+ KeyFrame *keyframe = plugin->get_keyframe();
+ presets_db->load_preset(plugin_title, title, keyframe, is_factory);
+#endif
+ mwindow->save_backup();
+ mwindow->undo->update_undo_after(_("apply preset"), LOAD_AUTOMATION);
+
+ mwindow->update_plugin_guis(0);
+ mwindow->gui->draw_overlays(1);
+ mwindow->sync_parameters(CHANGE_PARAMS);
+
+
+ update_gui(1);
+ mwindow->gui->unlock_window();
+ get_gui()->lock_window("KeyFrameThread::apply_preset");
+ }