From 2f991988c6b3d91652461fe70447e343fb3aa916 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 4 Oct 2007 01:28:27 +0000 Subject: Fixed port menu (load fancy dynamic menu from Glade). Renaming of JACK ports. git-svn-id: http://svn.drobilla.net/lad/ingen@820 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/DisconnectNodeEvent.cpp | 23 +++++-------- src/libs/engine/events/RenameEvent.cpp | 47 ++++++++++++++++++++------ 2 files changed, 45 insertions(+), 25 deletions(-) (limited to 'src/libs/engine/events') diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp index b1f76dd6..26f31549 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.cpp +++ b/src/libs/engine/events/DisconnectNodeEvent.cpp @@ -15,26 +15,23 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "DisconnectNodeEvent.hpp" -#include -#include #include +#include #include -#include "Responder.hpp" -#include "Engine.hpp" -#include "Node.hpp" +#include +#include "ClientBroadcaster.hpp" #include "Connection.hpp" +#include "DisconnectNodeEvent.hpp" #include "DisconnectionEvent.hpp" -#include "Port.hpp" +#include "Engine.hpp" #include "InputPort.hpp" +#include "Node.hpp" +#include "ObjectStore.hpp" #include "OutputPort.hpp" #include "Patch.hpp" -#include "ClientBroadcaster.hpp" +#include "Port.hpp" +#include "Responder.hpp" #include "util.hpp" -#include "ObjectStore.hpp" -#include - -using std::cerr; using std::endl; namespace Ingen { @@ -75,8 +72,6 @@ DisconnectNodeEvent::pre_process() { typedef Raul::List::const_iterator ConnectionListIterator; - // cerr << "Preparing disconnection event...\n"; - if (_lookup) { _patch = _engine.object_store()->find_patch(_node_path.parent()); diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp index 1ec3b0d1..9e5ef543 100644 --- a/src/libs/engine/events/RenameEvent.cpp +++ b/src/libs/engine/events/RenameEvent.cpp @@ -15,15 +15,17 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include "ClientBroadcaster.hpp" +#include "Engine.hpp" +#include "Node.hpp" +#include "ObjectStore.hpp" +#include "Patch.hpp" #include "RenameEvent.hpp" #include "Responder.hpp" -#include "Patch.hpp" -#include "Node.hpp" #include "Tree.hpp" -#include "Engine.hpp" -#include "ClientBroadcaster.hpp" -#include -#include "ObjectStore.hpp" +#include "AudioDriver.hpp" +#include "MidiDriver.hpp" using namespace std; @@ -34,7 +36,7 @@ RenameEvent::RenameEvent(Engine& engine, SharedPtr responder, SampleC : QueuedEvent(engine, responder, timestamp), _old_path(path), _name(name), - _new_path(_old_path.parent().base() + name), + _new_path("/"), _parent_patch(NULL), _store_iterator(engine.object_store()->objects().end()), _error(NO_ERROR) @@ -55,19 +57,27 @@ RenameEvent::~RenameEvent() void RenameEvent::pre_process() { - if (_name.find("/") != string::npos) { + if ((!Raul::Path::is_valid_name(_name)) || _name.find("/") != string::npos) { _error = INVALID_NAME; QueuedEvent::pre_process(); return; } + _new_path = _old_path.parent().base() + _name; + _store_iterator = _engine.object_store()->find(_old_path); if (_store_iterator == _engine.object_store()->objects().end()) { _error = OBJECT_NOT_FOUND; QueuedEvent::pre_process(); return; } - + + if (_engine.object_store()->find_object(_new_path)) { + _error = OBJECT_EXISTS; + QueuedEvent::pre_process(); + return; + } + Table removed = _engine.object_store()->remove(_store_iterator); assert(removed.size() > 0); @@ -81,7 +91,6 @@ RenameEvent::pre_process() else child_new_path = _new_path.base() + child_old_path.substr(_old_path.length()+1); - cerr << "Renamed " << child_old_path << " -> " << child_new_path << endl; i->second->set_path(child_new_path); i->first = child_new_path; } @@ -95,8 +104,24 @@ RenameEvent::pre_process() void RenameEvent::execute(ProcessContext& context) { - //cout << "Executing rename event..."; QueuedEvent::execute(context); + + Port* port = dynamic_cast(_store_iterator->second); + if (port && port->parent()->parent() == NULL) { + DriverPort* driver_port = NULL; + + if (port->type() == DataType::FLOAT) + driver_port = _engine.audio_driver()->driver_port(_new_path); + else if (port->type() == DataType::MIDI) + driver_port = _engine.midi_driver()->driver_port(_new_path); + + if (driver_port) { + cerr << "DRIVER PORT :)!" << endl; + driver_port->set_name(_new_path); + } else { + cerr << "NO DRIVER PORT :(" << endl; + } + } } -- cgit v1.2.1