summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AlsaDriver.cpp25
-rw-r--r--src/AlsaDriver.h5
-rw-r--r--src/JackDriver.cpp15
-rw-r--r--src/JackDriver.h1
-rw-r--r--src/Patchage.cpp4
-rw-r--r--src/Patchage.h17
-rw-r--r--src/PatchageModule.h6
7 files changed, 34 insertions, 39 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 43ee297..f868af9 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -33,7 +33,6 @@ using namespace LibFlowCanvas;
AlsaDriver::AlsaDriver(Patchage* app)
: m_app(app),
- m_canvas(app->canvas()),
m_seq(NULL)
{
}
@@ -180,7 +179,7 @@ AlsaDriver::refresh_ports()
// Application input/output ports go on the same module
if (!split) {
- m = m_canvas->find_module(client_name, InputOutput);
+ m = m_app->canvas()->find_module(client_name, InputOutput);
if (!m) {
m = boost::shared_ptr<PatchageModule>(new PatchageModule(m_app, client_name, InputOutput));
m->load_location();
@@ -207,10 +206,10 @@ AlsaDriver::refresh_ports()
else type = Output;
// See if an InputOutput module exists (maybe with Jack ports on it)
- m = m_canvas->find_module(client_name, InputOutput);
+ m = m_app->canvas()->find_module(client_name, InputOutput);
if (!m)
- m = m_canvas->find_module(client_name, type);
+ m = m_app->canvas()->find_module(client_name, type);
if (!m) {
m = boost::shared_ptr<PatchageModule>(
@@ -225,10 +224,10 @@ AlsaDriver::refresh_ports()
type = Input;
// See if an InputOutput module exists (maybe with Jack ports on it)
- m = m_canvas->find_module(client_name, InputOutput);
+ m = m_app->canvas()->find_module(client_name, InputOutput);
if (!m)
- m = m_canvas->find_module(client_name, type);
+ m = m_app->canvas()->find_module(client_name, type);
if (!m) {
m = boost::shared_ptr<PatchageModule>(
@@ -245,10 +244,10 @@ AlsaDriver::refresh_ports()
type = Output;
// See if an InputOutput module exists (maybe with Jack ports on it)
- m = m_canvas->find_module(client_name, InputOutput);
+ m = m_app->canvas()->find_module(client_name, InputOutput);
if (!m)
- m = m_canvas->find_module(client_name, type);
+ m = m_app->canvas()->find_module(client_name, type);
if (!m) {
m = boost::shared_ptr<PatchageModule>(
@@ -279,8 +278,8 @@ AlsaDriver::refresh_connections()
boost::shared_ptr<PatchageModule> m;
boost::shared_ptr<PatchagePort> p;
- for (ModuleMap::iterator i = m_canvas->modules().begin();
- i != m_canvas->modules().end(); ++i) {
+ for (ModuleMap::iterator i = m_app->canvas()->modules().begin();
+ i != m_app->canvas()->modules().end(); ++i) {
m = boost::dynamic_pointer_cast<PatchageModule>((*i).second);
if (m) {
for (PortVector::const_iterator j = m->ports().begin(); j != m->ports().end(); ++j) {
@@ -317,14 +316,14 @@ AlsaDriver::add_connections(boost::shared_ptr<PatchagePort> port)
while(!snd_seq_query_port_subscribers(m_seq, subsinfo)) {
const snd_seq_addr_t* connected_addr = snd_seq_query_subscribe_get_addr(subsinfo);
- connected_port = m_canvas->find_port(connected_addr);
+ connected_port = m_app->canvas()->find_port(connected_addr);
if (connected_port) {
- boost::shared_ptr<Connection> existing = m_canvas->get_connection(port, connected_port);
+ boost::shared_ptr<Connection> existing = m_app->canvas()->get_connection(port, connected_port);
if (existing) {
existing->set_flagged(false);
} else {
- m_canvas->add_connection(port, connected_port);
+ m_app->canvas()->add_connection(port, connected_port);
}
}
diff --git a/src/AlsaDriver.h b/src/AlsaDriver.h
index 27ddee9..86efce3 100644
--- a/src/AlsaDriver.h
+++ b/src/AlsaDriver.h
@@ -51,8 +51,6 @@ public:
bool disconnect(boost::shared_ptr<PatchagePort> src_port,
boost::shared_ptr<PatchagePort> dst_port);
- PatchageFlowCanvas* canvas() { return m_canvas; }
-
private:
void refresh_ports();
void refresh_connections();
@@ -66,8 +64,7 @@ private:
boost::shared_ptr<PatchagePort> create_port(boost::shared_ptr<PatchageModule> parent,
const string& name, bool is_input, snd_seq_addr_t addr);
- Patchage* m_app;
- PatchageFlowCanvas* m_canvas;
+ Patchage* m_app;
snd_seq_t* m_seq;
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 8147678..23f53a3 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -32,7 +32,6 @@ using namespace LibFlowCanvas;
JackDriver::JackDriver(Patchage* app)
: m_app(app),
- m_canvas(app->canvas()),
m_client(NULL)
{
}
@@ -91,7 +90,7 @@ JackDriver::detach()
void
JackDriver::destroy_all_ports()
{
- ModuleMap modules = m_canvas->modules(); // copy
+ ModuleMap modules = m_app->canvas()->modules(); // copy
for (ModuleMap::iterator m = modules.begin(); m != modules.end(); ++m) {
PortVector ports = m->second->ports(); // copy
for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p) {
@@ -178,7 +177,7 @@ JackDriver::refresh()
}
}
- boost::shared_ptr<PatchageModule> m = m_canvas->find_module(client1_name, type);
+ boost::shared_ptr<PatchageModule> m = m_app->canvas()->find_module(client1_name, type);
if (!m) {
m = boost::shared_ptr<PatchageModule>(new PatchageModule(m_app, client1_name, type));
@@ -212,7 +211,7 @@ JackDriver::refresh()
const string module_name = (*i).substr(0, i->find(":"));
const string port_name = (*i).substr(i->find(":")+1);
- for (ModuleMap::iterator m = m_canvas->modules().begin(); m != m_canvas->modules().end(); ++m) {
+ for (ModuleMap::iterator m = m_app->canvas()->modules().begin(); m != m_app->canvas()->modules().end(); ++m) {
if (m->second->name() == module_name)
m->second->remove_port(port_name);
}
@@ -235,15 +234,15 @@ JackDriver::refresh()
port2_name = client2_name.substr(client2_name.find(':')+1);
client2_name = client2_name.substr(0, client2_name.find(':'));
- boost::shared_ptr<Port> port1 = m_canvas->get_port(client1_name, port1_name);
- boost::shared_ptr<Port> port2 = m_canvas->get_port(client2_name, port2_name);
+ boost::shared_ptr<Port> port1 = m_app->canvas()->get_port(client1_name, port1_name);
+ boost::shared_ptr<Port> port2 = m_app->canvas()->get_port(client2_name, port2_name);
if (port1 && port2) {
- boost::shared_ptr<Connection> existing = m_canvas->get_connection(port1, port2);
+ boost::shared_ptr<Connection> existing = m_app->canvas()->get_connection(port1, port2);
if (existing) {
existing->set_flagged(false);
} else {
- m_canvas->add_connection(port1, port2);
+ m_app->canvas()->add_connection(port1, port2);
}
}
}
diff --git a/src/JackDriver.h b/src/JackDriver.h
index db74f77..e434ffc 100644
--- a/src/JackDriver.h
+++ b/src/JackDriver.h
@@ -56,7 +56,6 @@ public:
private:
Patchage* m_app;
- PatchageFlowCanvas* m_canvas;
jack_client_t* m_client;
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 0a37e58..e87d431 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -37,7 +37,6 @@ Patchage::Patchage(int argc, char** argv)
#ifdef HAVE_ALSA
m_alsa_driver(NULL),
#endif
- m_canvas(NULL),
m_jack_driver(NULL),
m_state_manager(NULL),
m_refresh(false)
@@ -46,7 +45,7 @@ Patchage::Patchage(int argc, char** argv)
m_settings_filename += "/.patchagerc";
m_state_manager = new StateManager();
- m_canvas = new PatchageFlowCanvas(this, 1600*2, 1200*2);
+ m_canvas = boost::shared_ptr<PatchageFlowCanvas>(new PatchageFlowCanvas(this, 1600*2, 1200*2));
m_jack_driver = new JackDriver(this);
#ifdef HAVE_ALSA
m_alsa_driver = new AlsaDriver(this);
@@ -159,7 +158,6 @@ Patchage::~Patchage()
delete m_lash_driver;
#endif
delete m_state_manager;
- delete m_canvas;
}
diff --git a/src/Patchage.h b/src/Patchage.h
index c7a3e0e..f303a46 100644
--- a/src/Patchage.h
+++ b/src/Patchage.h
@@ -19,6 +19,7 @@
#include "config.h"
#include <string>
+#include <boost/shared_ptr.hpp>
#include <libgnomecanvasmm.h>
using namespace std;
@@ -36,15 +37,16 @@ public:
Patchage(int argc, char** argv);
~Patchage();
- PatchageFlowCanvas* canvas() { return m_canvas; }
- StateManager* state_manager() { return m_state_manager; }
- Gtk::Window* window() { return m_main_window; }
- JackDriver* jack_driver() { return m_jack_driver; }
+ boost::shared_ptr<PatchageFlowCanvas> canvas() { return m_canvas; }
+
+ StateManager* state_manager() { return m_state_manager; }
+ Gtk::Window* window() { return m_main_window; }
+ JackDriver* jack_driver() { return m_jack_driver; }
#ifdef HAVE_ALSA
- AlsaDriver* alsa_driver() { return m_alsa_driver; }
+ AlsaDriver* alsa_driver() { return m_alsa_driver; }
#endif
#ifdef HAVE_LASH
- LashDriver* lash_driver() { return m_lash_driver; }
+ LashDriver* lash_driver() { return m_lash_driver; }
#endif
void attach();
@@ -85,7 +87,8 @@ protected:
void menu_alsa_disconnect();
#endif
- PatchageFlowCanvas* m_canvas;
+ boost::shared_ptr<PatchageFlowCanvas> m_canvas;
+
JackDriver* m_jack_driver;
StateManager* m_state_manager;
diff --git a/src/PatchageModule.h b/src/PatchageModule.h
index 58fa096..f58948d 100644
--- a/src/PatchageModule.h
+++ b/src/PatchageModule.h
@@ -35,7 +35,7 @@ class PatchageModule : public Module
{
public:
PatchageModule(Patchage* app, const string& title, ModuleType type, double x=0, double y=0)
- : Module(*app->canvas(), title, x, y),
+ : Module(app->canvas(), title, x, y),
m_app(app),
m_type(type)
{
@@ -79,8 +79,8 @@ public:
if (loc.x != -1)
move_to(loc.x, loc.y);
else
- move_to((m_canvas.width()/2) - 100 + rand() % 400,
- (m_canvas.height()/2) - 100 + rand() % 400);
+ move_to((m_canvas.lock()->width()/2) - 100 + rand() % 400,
+ (m_canvas.lock()->height()/2) - 100 + rand() % 400);
}
void split() {