+bool
+VSTPlugin::load_plugin_preset (PresetRecord r)
+{
+ /* This is a plugin-provided preset.
+ We can't dispatch directly here; too many plugins expects only one GUI thread.
+ */
+
+ /* Extract the index of this preset from the URI */
+ int id;
+ int index;
+#ifndef NDEBUG
+ int const p = sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
+ assert (p == 2);
+#else
+ sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
+#endif
+
+ _state->want_program = index;
+ return true;
+}
+
+bool
+VSTPlugin::load_user_preset (PresetRecord r)
+{
+ /* This is a user preset; we load it, and this code also knows about the
+ non-direct-dispatch thing.
+ */
+
+ boost::shared_ptr<XMLTree> t (presets_tree ());
+ if (t == 0) {
+ return false;
+ }
+
+ XMLNode* root = t->root ();
+
+ for (XMLNodeList::const_iterator i = root->children().begin(); i != root->children().end(); ++i) {
+ XMLProperty* label = (*i)->property (X_("label"));
+
+ assert (label);
+
+ if (label->value() != r.label) {
+ continue;
+ }
+
+ if (_plugin->flags & 32 /* effFlagsProgramsChunks */) {