summaryrefslogtreecommitdiffstats
path: root/src/progs/ingenuity
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs/ingenuity')
-rw-r--r--src/progs/ingenuity/LoadPluginWindow.cpp6
-rw-r--r--src/progs/ingenuity/PatchCanvas.cpp74
-rw-r--r--src/progs/ingenuity/PatchCanvas.h4
3 files changed, 81 insertions, 3 deletions
diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp
index 498f5d6f..2e58c67c 100644
--- a/src/progs/ingenuity/LoadPluginWindow.cpp
+++ b/src/progs/ingenuity/LoadPluginWindow.cpp
@@ -262,7 +262,9 @@ LoadPluginWindow::generate_module_name(int offset)
if (iter) {
Gtk::TreeModel::Row row = *iter;
SharedPtr<PluginModel> plugin = row.get_value(_plugins_columns._col_plugin_model);
- char num_buf[3];
+ return plugin->default_node_name(_patch);
+ }
+ /*char num_buf[3];
for (uint i=0; i < 99; ++i) {
name = plugin->default_node_name();
if (name == "")
@@ -277,7 +279,7 @@ LoadPluginWindow::generate_module_name(int offset)
else
name = "";
}
- }
+ }*/
return name;
}
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp
index 13ceaac0..af99d4d1 100644
--- a/src/progs/ingenuity/PatchCanvas.cpp
+++ b/src/progs/ingenuity/PatchCanvas.cpp
@@ -34,7 +34,12 @@
#include "GladeFactory.h"
#include "WindowFactory.h"
#include "Serializer.h"
+#include "Store.h"
+#include "PluginModel.h"
+#include "config.h"
+using Ingen::Client::Store;
using Ingen::Client::Serializer;
+using Ingen::Client::PluginModel;
namespace Ingenuity {
@@ -78,6 +83,8 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height)
sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port),
"midi_output", "ingen:midi", true));
+ build_plugin_menu();
+
// Connect to model signals to track state
_patch->new_node_sig.connect(sigc::mem_fun(this, &PatchCanvas::add_node));
_patch->removed_node_sig.connect(sigc::mem_fun(this, &PatchCanvas::remove_node));
@@ -94,6 +101,62 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height)
void
+PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu,
+ SLV2PluginClass plugin_class, SLV2PluginClasses classes)
+{
+#ifdef HAVE_SLV2
+ // Add submenus
+ for (unsigned i=0; i < slv2_plugin_classes_size(classes); ++i) {
+ SLV2PluginClass c = slv2_plugin_classes_get_at(classes, i);
+ const char* parent = slv2_plugin_class_get_parent_uri(c);
+
+ if (parent && !strcmp(parent, slv2_plugin_class_get_uri(plugin_class))) {
+ menu->items().push_back(Gtk::Menu_Helpers::MenuElem(
+ slv2_plugin_class_get_label(c)));
+ Gtk::MenuItem* menu_item = &(menu->items().back());
+ Gtk::Menu* submenu = Gtk::manage(new Gtk::Menu());
+ menu_item->set_submenu(*submenu);
+ build_plugin_class_menu(submenu, c, classes);
+ }
+ }
+
+
+ const Store::Plugins& plugins = App::instance().store()->plugins();
+
+ // Add plugins
+ for (Store::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
+ SLV2Plugin p = i->second->slv2_plugin();
+ if (p && slv2_plugin_get_class(p) == plugin_class)
+ menu->items().push_back(Gtk::Menu_Helpers::MenuElem(i->second->name(),
+ sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin),
+ i->second)));
+ }
+
+
+#endif
+}
+
+
+void
+PatchCanvas::build_plugin_menu()
+{
+#ifdef HAVE_SLV2
+ _menu->items().push_back(Gtk::Menu_Helpers::ImageMenuElem("Plugin",
+ *(manage(new Gtk::Image(Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU)))));
+ Gtk::MenuItem* plugin_menu_item = &(_menu->items().back());
+ Gtk::Menu* plugin_menu = Gtk::manage(new Gtk::Menu());
+ plugin_menu_item->set_submenu(*plugin_menu);
+ _menu->reorder_child(*plugin_menu_item, 2);
+
+ SLV2PluginClass lv2_plugin = slv2_world_get_plugin_class(PluginModel::slv2_world());
+ SLV2PluginClasses classes = slv2_world_get_plugin_classes(PluginModel::slv2_world());
+
+ build_plugin_class_menu(plugin_menu, lv2_plugin, classes);
+#endif
+}
+
+
+void
PatchCanvas::build()
{
boost::shared_ptr<PatchCanvas> shared_this =
@@ -118,7 +181,7 @@ PatchCanvas::build()
}
}
-
+
void
PatchCanvas::arrange()
{
@@ -397,6 +460,15 @@ PatchCanvas::menu_add_port(const string& name, const string& type, bool is_outpu
}
+void
+PatchCanvas::load_plugin(SharedPtr<PluginModel> plugin)
+{
+ const Path& path = _patch->path().base() + plugin->default_node_name(_patch);
+ // FIXME: polyphony?
+ App::instance().engine()->create_node_with_data(plugin->uri(), path, false, get_initial_data());
+}
+
+
/** Try to guess a suitable location for a new module.
*/
void
diff --git a/src/progs/ingenuity/PatchCanvas.h b/src/progs/ingenuity/PatchCanvas.h
index 64f72881..b36bd115 100644
--- a/src/progs/ingenuity/PatchCanvas.h
+++ b/src/progs/ingenuity/PatchCanvas.h
@@ -84,6 +84,10 @@ private:
void menu_load_plugin();
void menu_new_patch();
void menu_load_patch();
+ void load_plugin(SharedPtr<PluginModel> plugin);
+ void build_plugin_menu();
+ void build_plugin_class_menu(Gtk::Menu* menu,
+ SLV2PluginClass plugin_class, SLV2PluginClasses classes);
MetadataMap get_initial_data();