summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/ObjectModel.hpp10
-rw-r--r--src/client/PatchModel.cpp5
-rw-r--r--src/client/PatchModel.hpp2
-rw-r--r--src/client/PluginModel.cpp114
-rw-r--r--src/client/PluginModel.hpp11
-rw-r--r--src/common/interface/Resource.hpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp52
-rw-r--r--src/gui/LoadPluginWindow.hpp11
-rw-r--r--src/gui/PatchCanvas.cpp2
-rw-r--r--src/shared/ResourceImpl.cpp11
-rw-r--r--src/shared/ResourceImpl.hpp9
11 files changed, 103 insertions, 128 deletions
diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp
index 5029f024..840f9339 100644
--- a/src/client/ObjectModel.hpp
+++ b/src/client/ObjectModel.hpp
@@ -54,16 +54,16 @@ class ObjectModel : virtual public Ingen::Shared::GraphObject
public:
virtual ~ObjectModel();
- const Raul::Atom& get_property(const Raul::URI& key) const;
+ virtual const Raul::Atom& get_property(const Raul::URI& key) const;
- virtual void set_property(const Raul::URI& key, const Raul::Atom& value) {
- ResourceImpl::set_property(key, value);
+ virtual Raul::Atom& set_property(const Raul::URI& key, const Raul::Atom& value) {
signal_property.emit(key, value);
+ return ResourceImpl::set_property(key, value);
}
- virtual void set_meta_property(const Raul::URI& key, const Raul::Atom& value) {
- _meta.set_property(key, value);
+ virtual Raul::Atom& set_meta_property(const Raul::URI& key, const Raul::Atom& value) {
signal_property.emit(key, value);
+ return _meta.set_property(key, value);
}
Resource& meta() { return _meta; }
diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp
index baaa36ba..cec8b13b 100644
--- a/src/client/PatchModel.cpp
+++ b/src/client/PatchModel.cpp
@@ -169,12 +169,13 @@ PatchModel::enabled() const
}
-void
+Raul::Atom&
PatchModel::set_meta_property(const Raul::URI& key, const Atom& value)
{
- NodeModel::set_meta_property(key, value);
if (key.str() == "ingen:polyphony")
_poly = value.get_int32();
+
+ return NodeModel::set_meta_property(key, value);
}
diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp
index b52a4f8d..6b8398ae 100644
--- a/src/client/PatchModel.hpp
+++ b/src/client/PatchModel.hpp
@@ -60,7 +60,7 @@ public:
signal_editable.emit(e);
} }
- virtual void set_meta_property(const Raul::URI& key, const Raul::Atom& value);
+ virtual Raul::Atom& set_meta_property(const Raul::URI& key, const Raul::Atom& value);
// Signals
sigc::signal<void, SharedPtr<NodeModel> > signal_new_node;
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 0627326d..7998f8e2 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -17,6 +17,7 @@
#include <sstream>
#include <ctype.h>
+#include <boost/optional.hpp>
#include "ingen-config.h"
#include "raul/Path.hpp"
#include "raul/Atom.hpp"
@@ -40,22 +41,34 @@ Redland::World* PluginModel::_rdf_world = NULL;
PluginModel::PluginModel(const URI& uri, const URI& type_uri, const Resource::Properties& properties)
: ResourceImpl(uri)
- , _type(type_from_uri(_rdf_world->prefixes().qualify(type_uri.str())))
+ , _type(type_from_uri(type_uri.str()))
{
add_properties(properties);
Glib::Mutex::Lock lock(_rdf_world->mutex());
assert(_rdf_world);
- add_property("rdf:type", Raul::Atom(Raul::Atom::URI, this->type_uri()));
+ add_property("rdf:type", Atom(Atom::URI, this->type_uri()));
#ifdef HAVE_SLV2
SLV2Value plugin_uri = slv2_value_new_uri(_slv2_world, uri.c_str());
_slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri);
slv2_value_free(plugin_uri);
#endif
if (_type == Internal)
- set_property("doap:name", Raul::Atom(uri.substr(uri.find_last_of("#") + 1).c_str()));
+ set_property("doap:name", Atom(uri.substr(uri.find_last_of("#") + 1).c_str()));
+}
+
- if (!get_property("lv2:symbol").is_valid()) {
+const Atom&
+PluginModel::get_property(const URI& key) const
+{
+ static Atom nil_atom(Atom::NIL);
+ const Atom& val = ResourceImpl::get_property(key);
+ if (val.is_valid())
+ return val;
+
+ // No lv2:symbol from data or engine, invent one
+ if (key.str() == "lv2:symbol") {
+ const URI& uri = this->uri();
size_t last_slash = uri.find_last_of("/");
size_t last_hash = uri.find_last_of("#");
string symbol;
@@ -78,48 +91,51 @@ PluginModel::PluginModel(const URI& uri, const URI& type_uri, const Resource::Pr
symbol = uri.str().substr(first_delim + 1, last_delim - first_delim - 1);
}
set_property("lv2:symbol", Atom(Atom::STRING, symbol));
+ return get_property(key);
}
-}
-
-
-const std::string
-PluginModel::symbol()
-{
- const Atom& val = get_property("lv2:symbol");
- if (val.is_valid() && val.type() == Atom::STRING)
- return val.get_string();
#ifdef HAVE_SLV2
- SLV2Value lv2_symbol_pred = slv2_value_new_uri(_slv2_world,
- "http://lv2plug.in/ns/lv2core#symbol");
- SLV2Values symbols = slv2_plugin_get_value(_slv2_plugin, lv2_symbol_pred);
- for (unsigned i = 0; i < slv2_values_size(symbols); ++i) {
- SLV2Value val = slv2_values_get_at(symbols, 0);
- if (slv2_value_is_string(val)) {
- cerr << uri() << " FOUND SYMBOL: " << slv2_value_as_string(val) << endl;
- set_property("lv2:symbol", Atom(Atom::STRING, slv2_value_as_string(val)));
- break;
+ if (_slv2_plugin) {
+ boost::optional<Raul::Atom&> ret;
+ SLV2Value lv2_pred = slv2_value_new_uri(_slv2_world,
+ _rdf_world->expand_uri(key.str()).c_str());
+ SLV2Values values = slv2_plugin_get_value(_slv2_plugin, lv2_pred);
+ slv2_value_free(lv2_pred);
+ for (unsigned i = 0; i < slv2_values_size(values); ++i) {
+ SLV2Value val = slv2_values_get_at(values, 0);
+ if (slv2_value_is_uri(val)) {
+ ret = set_property(key, Atom(Atom::URI, slv2_value_as_uri(val)));
+ break;
+ } else if (slv2_value_is_string(val)) {
+ ret = set_property(key, Atom(Atom::STRING, slv2_value_as_string(val)));
+ break;
+ } else if (slv2_value_is_float(val)) {
+ ret = set_property(key, Atom(slv2_value_as_float(val)));
+ break;
+ } else if (slv2_value_is_int(val)) {
+ ret = set_property(key, Atom(slv2_value_as_int(val)));
+ break;
+ }
}
+ slv2_values_free(values);
+
+ if (ret)
+ return *ret;
}
- slv2_values_free(symbols);
- slv2_value_free(lv2_symbol_pred);
#endif
- return string_property("lv2:symbol");
+ return nil_atom;
}
-const std::string
-PluginModel::name()
-{
- return string_property("doap:name");
-}
-
-
-string
+Symbol
PluginModel::default_node_symbol()
{
- return Raul::Path::nameify(symbol());
+ const Atom& name_atom = get_property("lv2:symbol");
+ if (name_atom.is_valid() && name_atom.type() == Atom::STRING)
+ return Symbol::symbolify(name_atom.get_string());
+ else
+ return "_";
}
@@ -127,20 +143,10 @@ string
PluginModel::human_name()
{
const Atom& name_atom = get_property("doap:name");
- if (name_atom.type() == Atom::STRING)
+ if (name_atom.is_valid() && name_atom.type() == Atom::STRING)
return name_atom.get_string();
-
-#ifdef HAVE_SLV2
- if (_slv2_plugin) {
- SLV2Value name = slv2_plugin_get_name(_slv2_plugin);
- string ret = slv2_value_as_string(name);
- slv2_value_free(name);
- set_property("doap:name", Raul::Atom(Raul::Atom::STRING, ret.c_str()));
- return ret;
- }
-#endif
-
- return default_node_symbol();
+ else
+ return default_node_symbol();
}
@@ -150,9 +156,9 @@ PluginModel::port_human_name(uint32_t index) const
#ifdef HAVE_SLV2
if (_slv2_plugin) {
Glib::Mutex::Lock lock(_rdf_world->mutex());
- SLV2Port port = slv2_plugin_get_port_by_index(_slv2_plugin, index);
+ SLV2Port port = slv2_plugin_get_port_by_index(_slv2_plugin, index);
SLV2Value name = slv2_port_get_name(_slv2_plugin, port);
- string ret = slv2_value_as_string(name);
+ string ret = slv2_value_as_string(name);
slv2_value_free(name);
return ret;
}
@@ -227,15 +233,5 @@ PluginModel::get_lv2_icon_path(SLV2Plugin plugin)
#endif
-const string
-PluginModel::string_property(const std::string& name) const
-{
- const Raul::Atom& atom = get_property(name);
- if (atom.type() == Raul::Atom::STRING)
- return atom.get_string();
- else
- return "";
-}
-
} // namespace Client
} // namespace Ingen
diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp
index bc7271b9..90440efe 100644
--- a/src/client/PluginModel.hpp
+++ b/src/client/PluginModel.hpp
@@ -53,12 +53,11 @@ public:
Type type() const { return _type; }
- const std::string symbol();
- const std::string name();
+ virtual const Raul::Atom& get_property(const Raul::URI& key) const;
- std::string default_node_symbol();
- std::string human_name();
- std::string port_human_name(uint32_t index) const;
+ Raul::Symbol default_node_symbol();
+ std::string human_name();
+ std::string port_human_name(uint32_t index) const;
#ifdef HAVE_SLV2
static SLV2World slv2_world() { return _slv2_world; }
@@ -93,8 +92,6 @@ public:
private:
const Type _type;
- const std::string string_property(const std::string& name) const;
-
#ifdef HAVE_SLV2
static SLV2World _slv2_world;
static SLV2Plugins _slv2_plugins;
diff --git a/src/common/interface/Resource.hpp b/src/common/interface/Resource.hpp
index 7512bfe7..194e99cf 100644
--- a/src/common/interface/Resource.hpp
+++ b/src/common/interface/Resource.hpp
@@ -36,8 +36,8 @@ public:
virtual const Properties& properties() const = 0;
virtual Properties& properties() = 0;
- virtual void set_property(const Raul::URI& uri,
- const Raul::Atom& value) = 0;
+ virtual Raul::Atom& set_property(const Raul::URI& uri,
+ const Raul::Atom& value) = 0;
virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0;
};
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index 4b024c8d..260641a9 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -63,14 +63,9 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr<G
_plugins_treeview->get_column(1)->set_sort_column(_plugins_columns._col_name);
_plugins_treeview->get_column(2)->set_sort_column(_plugins_columns._col_type);
_plugins_treeview->get_column(3)->set_sort_column(_plugins_columns._col_uri);
- //m_plugins_treeview->get_column(3)->set_sort_column(_plugins_columns._col_library);
- //m_plugins_treeview->get_column(4)->set_sort_column(_plugins_columns._col_label);
for (int i=0; i < 3; ++i)
_plugins_treeview->get_column(i)->set_resizable(true);
- _plugins_liststore->set_default_sort_func(
- sigc::mem_fun(this, &LoadPluginWindow::plugin_compare));
-
// Set up the search criteria combobox
_criteria_liststore = Gtk::ListStore::create(_criteria_columns);
_filter_combo->set_model(_criteria_liststore);
@@ -189,28 +184,6 @@ LoadPluginWindow::on_show()
}
-int
-LoadPluginWindow::plugin_compare(const Gtk::TreeModel::iterator& a_i,
- const Gtk::TreeModel::iterator& b_i)
-{
- SharedPtr<PluginModel> a = a_i->get_value(_plugins_columns._col_plugin_model);
- SharedPtr<PluginModel> b = b_i->get_value(_plugins_columns._col_plugin_model);
-
- // FIXME: haaack
- if (!a && !b)
- return 0;
- else if (!a)
- return 1;
- else if (!b)
- return -1;
-
- if (a->type() == b->type())
- return strcmp(a->name().c_str(), b->name().c_str());
- else
- return ((int)a->type() < (int)b->type()) ? -1 : 1;
-}
-
-
void
LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> m)
{
@@ -221,8 +194,9 @@ LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> m)
add_plugin(i->second);
}
- _plugins_liststore->set_sort_column(
- Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID, Gtk::SORT_ASCENDING);
+ _plugins_liststore->set_sort_column(1,
+ //Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID,
+ Gtk::SORT_ASCENDING);
_plugins_treeview->columns_autosize();
}
@@ -245,7 +219,9 @@ LoadPluginWindow::add_plugin(SharedPtr<PluginModel> plugin)
Gtk::TreeModel::Row row = *iter;
_rows.insert(make_pair(plugin->uri(), iter));
- row[_plugins_columns._col_name] = plugin->name();
+ const Atom& name = plugin->get_property("doap:name");
+ if (name.is_valid() && name.type() == Atom::STRING)
+ row[_plugins_columns._col_name] = name.get_string();
if (!strcmp(plugin->type_uri(), "ingen:Internal"))
row[_plugins_columns._col_type] = "Internal";
else if (!strcmp(plugin->type_uri(), "lv2:Plugin"))
@@ -255,15 +231,11 @@ LoadPluginWindow::add_plugin(SharedPtr<PluginModel> plugin)
else
row[_plugins_columns._col_type] = plugin->type_uri();
row[_plugins_columns._col_uri] = plugin->uri().str();
- row[_plugins_columns._col_label] = plugin->name();
row[_plugins_columns._col_plugin_model] = plugin;
plugin->signal_property.connect(sigc::bind<0>(
sigc::mem_fun(this, &LoadPluginWindow::plugin_property_changed),
plugin->uri()));
-
- if (plugin->name() == "")
- App::instance().engine()->request_property(plugin->uri(), "doap:name");
}
@@ -398,10 +370,13 @@ LoadPluginWindow::filter_changed()
i != App::instance().store()->plugins()->end(); ++i) {
const SharedPtr<PluginModel> plugin = (*i).second;
+ const Atom& name = plugin->get_property("doap:name");
switch (criteria) {
case CriteriaColumns::NAME:
- field = plugin->name(); break;
+ if (name.is_valid() && name.type() == Atom::STRING)
+ field = name.get_string();
+ break;
case CriteriaColumns::TYPE:
field = plugin->type_uri(); break;
case CriteriaColumns::URI:
@@ -416,9 +391,9 @@ LoadPluginWindow::filter_changed()
model_iter = _plugins_liststore->append();
model_row = *model_iter;
- model_row[_plugins_columns._col_name] = plugin->name();
- model_row[_plugins_columns._col_type] = plugin->type_uri();
- model_row[_plugins_columns._col_uri] = plugin->uri().str();
+ model_row[_plugins_columns._col_name] = name.is_valid() ? name.get_string() : "";
+ model_row[_plugins_columns._col_type] = plugin->type_uri();
+ model_row[_plugins_columns._col_uri] = plugin->uri().str();
model_row[_plugins_columns._col_plugin_model] = plugin;
++num_visible;
@@ -456,6 +431,7 @@ LoadPluginWindow::plugin_property_changed(const URI& plugin,
const URI& predicate,
const Atom& value)
{
+ cerr << "PLUGIN PROPERTY " << plugin << " : " << predicate << " = " << value << endl;
Rows::const_iterator i = _rows.find(plugin);
if (i != _rows.end() && value.type() == Atom::STRING)
(*i->second)[_plugins_columns._col_name] = value.get_string();
diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp
index 8270d106..39582998 100644
--- a/src/gui/LoadPluginWindow.hpp
+++ b/src/gui/LoadPluginWindow.hpp
@@ -52,17 +52,15 @@ public:
add(_col_name);
add(_col_type);
add(_col_uri);
- add(_col_label);
add(_col_plugin_model);
}
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > _col_icon;
- Gtk::TreeModelColumn<Glib::ustring> _col_name;
- Gtk::TreeModelColumn<Glib::ustring> _col_type;
- Gtk::TreeModelColumn<Glib::ustring> _col_uri;
+ Gtk::TreeModelColumn<Glib::ustring> _col_name;
+ Gtk::TreeModelColumn<Glib::ustring> _col_type;
+ Gtk::TreeModelColumn<Glib::ustring> _col_uri;
// Not displayed:
- Gtk::TreeModelColumn<Glib::ustring> _col_label;
Gtk::TreeModelColumn<SharedPtr<PluginModel> > _col_plugin_model;
};
@@ -119,9 +117,6 @@ private:
const Raul::URI& predicate,
const Raul::Atom& value);
- int plugin_compare(const Gtk::TreeModel::iterator& a,
- const Gtk::TreeModel::iterator& b);
-
void plugin_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* col);
void plugin_selection_changed();
std::string generate_module_name(int offset = 0);
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 827a181b..6c6f6529 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -313,7 +313,7 @@ void
PatchCanvas::add_plugin(SharedPtr<PluginModel> p)
{
if (_internal_menu && p->type() == Plugin::Internal) {
- _internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->name(),
+ _internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->human_name(),
sigc::bind(sigc::mem_fun(this, &PatchCanvas::load_plugin), p)));
} else if (_plugin_menu && p->type() == Plugin::LV2) {
SLV2PluginClass pc = slv2_plugin_get_class(p->slv2_plugin());
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index ca3eaacd..ac828f58 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -47,11 +47,18 @@ ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value)
}
-void
+Raul::Atom&
ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value)
{
_properties.erase(uri);
- _properties.insert(make_pair(uri, value));
+ return _properties.insert(make_pair(uri, value))->second;
+}
+
+
+Raul::Atom&
+ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value) const
+{
+ return const_cast<ResourceImpl*>(this)->set_property(uri, value);
}
diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp
index 118d4dbe..36d4305e 100644
--- a/src/shared/ResourceImpl.hpp
+++ b/src/shared/ResourceImpl.hpp
@@ -38,7 +38,7 @@ public:
Properties& properties() { return _properties; }
const Raul::Atom& get_property(const Raul::URI& uri) const;
- void set_property(const Raul::URI& uri, const Raul::Atom& value);
+ Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value);
void add_property(const Raul::URI& uri, const Raul::Atom& value);
void set_properties(const Properties& p);
void add_properties(const Properties& p);
@@ -57,9 +57,12 @@ public:
static const Raul::URI meta_uri(const Raul::URI& base, const Raul::URI& uri);
+protected:
+ Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;
+
private:
- Raul::URI _uri;
- Properties _properties;
+ Raul::URI _uri;
+ mutable Properties _properties;
};