diff options
-rw-r--r-- | src/client/ClientStore.cpp | 8 | ||||
-rw-r--r-- | src/client/ObjectModel.cpp | 19 | ||||
-rw-r--r-- | src/client/ObjectModel.hpp | 4 | ||||
-rw-r--r-- | src/engine/GraphObjectImpl.cpp | 2 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.cpp | 6 | ||||
-rw-r--r-- | src/gui/RenameWindow.cpp | 69 | ||||
-rw-r--r-- | src/gui/RenameWindow.hpp | 6 | ||||
-rw-r--r-- | src/gui/ingen_gui.glade | 55 | ||||
-rw-r--r-- | src/shared/ResourceImpl.cpp | 9 | ||||
-rw-r--r-- | src/shared/ResourceImpl.hpp | 4 |
10 files changed, 127 insertions, 55 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index b0b6bdbf..5f379035 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -253,13 +253,13 @@ void ClientStore::put(const URI& uri, const Resource::Properties& properties) { typedef Resource::Properties::const_iterator iterator; - /*cerr << "CLIENT PUT " << uri << " {" << endl; + cerr << "CLIENT PUT " << uri << " {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; - cerr << "}" << endl;*/ + cerr << "}" << endl; bool is_path = Path::is_valid(uri.str()); - bool is_meta = uri.substr(0, 6) == "meta:#"; + bool is_meta = ResourceImpl::is_meta_uri(uri); if (!(is_path || is_meta)) { const URI& type_uri = properties.find("rdf:type")->second.get_uri(); @@ -366,7 +366,7 @@ ClientStore::set_property(const URI& subject_uri, const URI& predicate, const At cerr << "ERROR: Property '" << predicate << "' is invalid" << endl; } else if (subject) { subject->set_property(predicate, value); - } else if (subject_uri.substr(0, 6) == "meta:#") { + } else if (ResourceImpl::is_meta_uri(subject_uri)) { Path instance_path = string("/") + subject_uri.substr(hash + 1); SharedPtr<ObjectModel> om = PtrCast<ObjectModel>(subject); if (om) diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 3ffd96bd..e41be6c9 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -29,7 +29,7 @@ namespace Client { ObjectModel::ObjectModel(const Path& path) : ResourceImpl(path) - , _meta(std::string("meta:#") + path.chop_start("/")) + , _meta(ResourceImpl::meta_uri(path)) , _path(path) { } @@ -103,6 +103,23 @@ ObjectModel::set(SharedPtr<ObjectModel> o) } +void +ObjectModel::set_path(const Raul::Path& p) +{ + _path = p; + _meta.set_uri(ResourceImpl::meta_uri(_path)); + signal_moved.emit(); +} + + +void +ObjectModel::set_parent(SharedPtr<ObjectModel> p) +{ + assert(p); + _parent = p; +} + + } // namespace Client } // namespace Ingen diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index 72692d65..9b0544f6 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -82,8 +82,8 @@ protected: ObjectModel(const Raul::Path& path); - virtual void set_path(const Raul::Path& p) { _path = p; signal_moved.emit(); } - virtual void set_parent(SharedPtr<ObjectModel> p) { assert(p); _parent = p; } + virtual void set_path(const Raul::Path& p); + virtual void set_parent(SharedPtr<ObjectModel> p); virtual void add_child(SharedPtr<ObjectModel> c) {} virtual bool remove_child(SharedPtr<ObjectModel> c) { return true; } diff --git a/src/engine/GraphObjectImpl.cpp b/src/engine/GraphObjectImpl.cpp index 40cdc792..50b0e58b 100644 --- a/src/engine/GraphObjectImpl.cpp +++ b/src/engine/GraphObjectImpl.cpp @@ -32,7 +32,7 @@ GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const std::string& nam : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name) , _parent(parent) , _name(name) - , _meta(std::string("meta:#") + path().chop_start("/")) + , _meta(ResourceImpl::meta_uri(uri())) , _polyphonic(polyphonic) { assert(parent == NULL || _name.length() > 0); diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 09e711cc..421342e5 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -155,14 +155,14 @@ void QueuedEngineInterface::put(const URI& uri, const Resource::Properties& properties) { - bool meta = uri.substr(0, 6) == "meta:#"; + bool meta = ResourceImpl::is_meta_uri(uri); URI subject(meta ? (string("path:/") + uri.substr(6)) : uri.str()); - /*cerr << "ENGINE PUT " << subject << " {" << endl; + cerr << "ENGINE PUT " << subject << " {" << endl; typedef Resource::Properties::const_iterator iterator; for (iterator i = properties.begin(); i != properties.end(); ++i) cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; - cerr << "}" << endl;*/ + cerr << "}" << endl; push_queued(new Events::SetMetadata(_engine, _responder, now(), this, true, meta, subject, properties)); } diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp index b6c41e68..32210466 100644 --- a/src/gui/RenameWindow.cpp +++ b/src/gui/RenameWindow.cpp @@ -33,12 +33,14 @@ namespace GUI { RenameWindow::RenameWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml) : Window(cobject) { - glade_xml->get_widget("rename_name_entry", _name_entry); + glade_xml->get_widget("rename_symbol_entry", _symbol_entry); + glade_xml->get_widget("rename_label_entry", _label_entry); glade_xml->get_widget("rename_message_label", _message_label); glade_xml->get_widget("rename_cancel_button", _cancel_button); glade_xml->get_widget("rename_ok_button", _ok_button); - _name_entry->signal_changed().connect(sigc::mem_fun(this, &RenameWindow::name_changed)); + _symbol_entry->signal_changed().connect(sigc::mem_fun(this, &RenameWindow::symbol_changed)); + _label_entry->signal_changed().connect(sigc::mem_fun(this, &RenameWindow::label_changed)); _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &RenameWindow::cancel_clicked)); _ok_button->signal_clicked().connect(sigc::mem_fun(this, &RenameWindow::ok_clicked)); @@ -53,7 +55,10 @@ void RenameWindow::set_object(SharedPtr<ObjectModel> object) { _object = object; - _name_entry->set_text(object->path().name()); + _symbol_entry->set_text(object->path().name()); + const Atom& name_atom = object->get_property("lv2:name"); + _label_entry->set_text( + (name_atom.type() == Atom::STRING) ? name_atom.get_string() : ""); } @@ -61,7 +66,7 @@ void RenameWindow::present(SharedPtr<ObjectModel> object) { set_object(object); - _name_entry->grab_focus(); + _symbol_entry->grab_focus(); Gtk::Window::present(); } @@ -70,28 +75,31 @@ RenameWindow::present(SharedPtr<ObjectModel> object) * Used to display warning messages, and enable/disable the rename button. */ void -RenameWindow::name_changed() +RenameWindow::symbol_changed() { - assert(_name_entry); - assert(_message_label); - assert(_object); - assert(_object->parent()); - - string name = _name_entry->get_text(); - if (name.find("/") != string::npos) { - _message_label->set_text("Name may not contain '/'"); + const string& symbol = _symbol_entry->get_text(); + if (symbol.length() == 0) { + _message_label->set_text("Symbol must be at least 1 character"); _ok_button->property_sensitive() = false; - } else if (!Path::is_valid_name(name)) { - _message_label->set_text("Name contains invalid characters"); + } else if (!Path::is_valid_name(symbol)) { + _message_label->set_text("Symbol contains invalid characters"); _ok_button->property_sensitive() = false; - } else if (name == _object->path().name()) { - _message_label->set_text(""); - _ok_button->property_sensitive() = false; - } else if ((App::instance().store()->object(_object->parent()->path().base() + name))) { - _message_label->set_text("An object already exists with that name."); + } else if (App::instance().store()->object(_object->parent()->path().base() + symbol)) { + _message_label->set_text("An object already exists with that path"); _ok_button->property_sensitive() = false; - } else if (name.length() == 0) { + } else { _message_label->set_text(""); + _ok_button->property_sensitive() = true; + } +} + + +void +RenameWindow::label_changed() +{ + const string& label = _label_entry->get_text(); + if (label == "") { + _message_label->set_text("Label must be at least 1 character"); _ok_button->property_sensitive() = false; } else { _message_label->set_text(""); @@ -103,7 +111,7 @@ RenameWindow::name_changed() void RenameWindow::cancel_clicked() { - _name_entry->set_text(""); + _symbol_entry->set_text(""); hide(); } @@ -117,11 +125,20 @@ RenameWindow::cancel_clicked() void RenameWindow::ok_clicked() { - string name = _name_entry->get_text(); - assert(name.length() > 0); - assert(name.find("/") == string::npos); + const string& symbol = _symbol_entry->get_text(); + const string& label = _label_entry->get_text(); + Path path = _object->path(); + const Atom& name_atom = _object->get_property("lv2:name"); + + if (Path::is_valid_name(symbol) && symbol != _object->path().name()) { + path = _object->path().parent().base() + symbol; + App::instance().engine()->move(_object->path(), path); + } - App::instance().engine()->move(_object->path(), _object->path().parent().base() + name); + if (label != "" && (!name_atom.is_valid() || label != name_atom.get_string())) { + App::instance().engine()->set_property(path, + "lv2:name", Atom(Atom::STRING, label)); + } hide(); } diff --git a/src/gui/RenameWindow.hpp b/src/gui/RenameWindow.hpp index 0e014534..360fc36f 100644 --- a/src/gui/RenameWindow.hpp +++ b/src/gui/RenameWindow.hpp @@ -44,13 +44,15 @@ public: private: void set_object(SharedPtr<ObjectModel> object); - void name_changed(); + void symbol_changed(); + void label_changed(); void cancel_clicked(); void ok_clicked(); SharedPtr<ObjectModel> _object; - Gtk::Entry* _name_entry; + Gtk::Entry* _symbol_entry; + Gtk::Entry* _label_entry; Gtk::Label* _message_label; Gtk::Button* _cancel_button; Gtk::Button* _ok_button; diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index 462b3273..3d42a76d 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -2141,35 +2141,64 @@ <property name="width_request">250</property> <property name="title" translatable="yes">Rename</property> <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> <property name="type_hint">dialog</property> <child> - <widget class="GtkVBox" id="vbox15"> + <widget class="GtkVBox" id="vbox1"> <property name="visible">True</property> <property name="border_width">5</property> + <property name="orientation">vertical</property> <child> - <widget class="GtkHBox" id="hbox53"> + <widget class="GtkTable" id="table2"> <property name="visible">True</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="row_spacing">8</property> <child> <widget class="GtkLabel" id="label95"> <property name="visible">True</property> - <property name="label" translatable="yes">New name: </property> + <property name="label" translatable="yes">Symbol: </property> </widget> <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="rename_label_entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label95"> + <property name="visible">True</property> + <property name="label" translatable="yes">Label: </property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> </packing> </child> <child> - <widget class="GtkEntry" id="rename_name_entry"> + <widget class="GtkEntry" id="rename_symbol_entry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="has_focus">True</property> - <property name="is_focus">True</property> + <property name="invisible_char">●</property> <property name="activates_default">True</property> </widget> <packing> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> </packing> </child> </widget> @@ -2180,18 +2209,16 @@ <child> <widget class="GtkLabel" id="rename_message_label"> <property name="visible">True</property> - <property name="wrap">True</property> </widget> <packing> - <property name="expand">False</property> - <property name="padding">6</property> + <property name="padding">12</property> <property name="position">1</property> </packing> </child> <child> <widget class="GtkHButtonBox" id="hbuttonbox4"> <property name="visible">True</property> - <property name="spacing">5</property> + <property name="spacing">8</property> <property name="layout_style">end</property> <child> <widget class="GtkButton" id="rename_cancel_button"> @@ -2199,7 +2226,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> - <property name="receives_default">False</property> + <property name="receives_default">True</property> <property name="use_stock">True</property> </widget> <packing> diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 6af25ef0..93d6ea03 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -25,8 +25,15 @@ namespace Ingen { namespace Shared { +bool +ResourceImpl::is_meta_uri(const Raul::URI& uri) +{ + return uri.substr(0, 6) == "meta:#"; +} + + const Raul::URI -ResourceImpl::meta_uri(const Raul::URI& base, const Raul::URI& uri) +ResourceImpl::meta_uri(const Raul::URI& uri) { return string("meta:#") + uri.chop_start("/"); } diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index 9b10ec15..b4afc50a 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -32,6 +32,7 @@ class ResourceImpl : virtual public Resource public: ResourceImpl(const Raul::URI& uri) : _uri(uri) {} + virtual void set_uri(const Raul::URI& uri) { _uri = uri; } virtual const Raul::URI uri() const { return _uri.str(); } const Properties& properties() const { return _properties; } @@ -55,7 +56,8 @@ public: bool& node, bool& port, bool& is_output, PortType& data_type); - static const Raul::URI meta_uri(const Raul::URI& base, const Raul::URI& uri); + static bool is_meta_uri(const Raul::URI& uri); + static const Raul::URI meta_uri(const Raul::URI& uri); protected: Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; |