summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/engine/Engine.cpp11
-rw-r--r--src/libs/engine/Engine.h2
-rw-r--r--src/libs/gui/App.cpp7
-rw-r--r--src/libs/gui/App.h5
-rw-r--r--src/libs/gui/ConnectWindow.cpp94
-rw-r--r--src/libs/gui/ConnectWindow.h4
-rw-r--r--src/progs/ingen/main.cpp13
7 files changed, 94 insertions, 42 deletions
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index 1d54aef6..af26d089 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -167,6 +167,17 @@ Engine::new_queued_interface()
return result;
}
+/*
+void
+Engine::set_event_source(SharedPtr<EventSource> source)
+{
+ if (_event_source)
+ cerr << "Warning: Dropped event source (engine interface)" << endl;
+
+ _event_source = source;
+}
+*/
+
bool
Engine::activate()
diff --git a/src/libs/engine/Engine.h b/src/libs/engine/Engine.h
index ad4332ee..bdb6cdfb 100644
--- a/src/libs/engine/Engine.h
+++ b/src/libs/engine/Engine.h
@@ -68,6 +68,8 @@ public:
virtual void start_osc_driver(int port);
virtual SharedPtr<QueuedEngineInterface> new_queued_interface();
+
+ //virtual void set_event_source(SharedPtr<EventSource>);
virtual bool activate();
virtual void deactivate();
diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp
index 928e5f5e..628a4adf 100644
--- a/src/libs/gui/App.cpp
+++ b/src/libs/gui/App.cpp
@@ -95,7 +95,9 @@ App::~App()
void
-App::run(int argc, char** argv)
+App::run(int argc, char** argv,
+ SharedPtr<Engine> engine,
+ SharedPtr<Shared::EngineInterface> interface)
{
Gnome::Canvas::init();
Gtk::Main main(argc, argv);
@@ -108,7 +110,8 @@ App::run(int argc, char** argv)
_instance->configuration()->apply_settings();
Gtk::Window::set_default_icon_from_file(PKGDATADIR "/ingen.svg");
- App::instance().connect_window()->start();
+
+ App::instance().connect_window()->start(engine, interface);
main.run();
}
diff --git a/src/libs/gui/App.h b/src/libs/gui/App.h
index 504c6920..9173a786 100644
--- a/src/libs/gui/App.h
+++ b/src/libs/gui/App.h
@@ -32,6 +32,7 @@ using std::string; using std::map; using std::list;
using std::cerr; using std::endl;
namespace Ingen {
+ class Engine;
namespace Shared {
class EngineInterface;
}
@@ -100,7 +101,9 @@ public:
static inline App& instance() { assert(_instance); return *_instance; }
- static void run(int argc, char** argv);
+ static void run(int argc, char** argv,
+ SharedPtr<Ingen::Engine> engine,
+ SharedPtr<Shared::EngineInterface> interface);
protected:
App();
diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp
index 367a38fc..40468a74 100644
--- a/src/libs/gui/ConnectWindow.cpp
+++ b/src/libs/gui/ConnectWindow.cpp
@@ -105,32 +105,72 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::
void
-ConnectWindow::start()
+ConnectWindow::start(SharedPtr<Ingen::Engine> engine, SharedPtr<Shared::EngineInterface> interface)
{
- resize(100, 100);
- init();
+ set_connected_to(interface);
show();
- connect();
+
+ if (engine) {
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(engine.get(), &Ingen::Engine::main_iteration), 1000);
+
+ ThreadedSigClientInterface* tsci = new ThreadedSigClientInterface(Ingen::event_queue_size);
+ SharedPtr<SigClientInterface> client(tsci);
+
+ if (interface) {
+ App::instance().attach(interface, client);
+ interface->set_responder(SharedPtr<Ingen::Shared::Responder>(new Ingen::DirectResponder(client, 1)));
+ }
+
+ engine->activate();
+
+ _connect_stage = 0;
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(engine.get(), &Ingen::Engine::main_iteration), 1000);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 2, G_PRIORITY_HIGH_IDLE);
+ }
+
+ if (interface) {
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100);
+ } else {
+ connect();
+ }
}
void
-ConnectWindow::init()
+ConnectWindow::set_connected_to(SharedPtr<Shared::EngineInterface> engine)
{
- _icon->set(Gtk::Stock::DISCONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR);
- _progress_bar->set_fraction(0.0);
- _url_entry->set_sensitive(true);
- _connect_button->set_sensitive(true);
- _disconnect_button->set_sensitive(false);
- _port_spinbutton->set_sensitive(false);
- _launch_radio->set_sensitive(true);
- if (_new_engine)
- _internal_radio->set_sensitive(true);
- else
+ if (engine) {
+ _icon->set(Gtk::Stock::CONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ _progress_bar->set_fraction(1.0);
+ _url_entry->set_sensitive(false);
+ _connect_button->set_sensitive(false);
+ _disconnect_button->set_label("gtk-disconnect");
+ _disconnect_button->set_sensitive(true);
+ _port_spinbutton->set_sensitive(false);
+ _launch_radio->set_sensitive(false);
_internal_radio->set_sensitive(false);
- server_toggled();
-
- _progress_label->set_text(string("Disconnected"));
+ } else {
+ _icon->set(Gtk::Stock::DISCONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ _progress_bar->set_fraction(0.0);
+ _url_entry->set_sensitive(true);
+ _connect_button->set_sensitive(true);
+ _disconnect_button->set_sensitive(false);
+ _port_spinbutton->set_sensitive(false);
+ _launch_radio->set_sensitive(true);
+ if (_new_engine)
+ _internal_radio->set_sensitive(true);
+ else
+ _internal_radio->set_sensitive(false);
+ server_toggled();
+
+ _progress_label->set_text(string("Disconnected"));
+ }
}
@@ -206,8 +246,6 @@ ConnectWindow::connect()
engine_interface->set_responder(SharedPtr<Ingen::Shared::Responder>(new Ingen::DirectResponder(client, 1)));
- //engine->set_event_source(engine_interface);
-
engine->activate();
Glib::signal_timeout().connect(
@@ -234,7 +272,7 @@ ConnectWindow::disconnect()
App::instance().detach();
- init();
+ set_connected_to();
_connect_button->set_sensitive(true);
_disconnect_button->set_sensitive(false);
@@ -289,9 +327,7 @@ ConnectWindow::internal_toggled()
bool
ConnectWindow::gtk_callback()
{
- /* This isn't very nice (isn't threaded), but better than no dialog at
- * all like before :)
- */
+ /* If I call this a "state machine" it's not ugly code any more */
// Timing stuff for repeated attach attempts
timeval now;
@@ -392,15 +428,7 @@ ConnectWindow::gtk_callback()
++_connect_stage;
hide();
} else if (_connect_stage == 10) {
- _icon->set(Gtk::Stock::CONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR);
- _progress_bar->set_fraction(1.0);
- _url_entry->set_sensitive(false);
- _connect_button->set_sensitive(false);
- _disconnect_button->set_label("gtk-disconnect");
- _disconnect_button->set_sensitive(true);
- _port_spinbutton->set_sensitive(false);
- _launch_radio->set_sensitive(false);
- _internal_radio->set_sensitive(false);
+ set_connected_to(App::instance().engine());
_connect_stage = 0; // set ourselves up for next time (if there is one)
return false; // deregister this callback
}
diff --git a/src/libs/gui/ConnectWindow.h b/src/libs/gui/ConnectWindow.h
index 1a4a654e..a52bbea2 100644
--- a/src/libs/gui/ConnectWindow.h
+++ b/src/libs/gui/ConnectWindow.h
@@ -46,7 +46,8 @@ class ConnectWindow : public Gtk::Dialog
public:
ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml);
- void start();
+ void set_connected_to(SharedPtr<Shared::EngineInterface> e=SharedPtr<Shared::EngineInterface>());
+ void start(SharedPtr<Ingen::Engine> engine, SharedPtr<Shared::EngineInterface> interface);
void response_received(int32_t id, bool, string) { if ((id) == _ping_id) _attached = true; }
private:
@@ -56,7 +57,6 @@ private:
void launch_toggled();
void internal_toggled();
- void init();
void disconnect();
void connect();
void quit();
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
index 57b8bf5c..62bc29aa 100644
--- a/src/progs/ingen/main.cpp
+++ b/src/progs/ingen/main.cpp
@@ -68,9 +68,9 @@ main(int argc, char** argv)
SharedPtr<Glib::Module> client_module;
SharedPtr<Glib::Module> gui_module;
-
SharedPtr<Shared::EngineInterface> engine_interface;
+
/* Run engine */
if (args.engine_flag) {
@@ -93,7 +93,7 @@ main(int argc, char** argv)
} else {
engine_module.reset();
}
- engine_interface = engine->new_queued_interface();
+
/*} else {
cerr << "Nonsense command line parameters, engine not loaded." << endl;
}*/
@@ -103,6 +103,11 @@ main(int argc, char** argv)
}
}
+
+ if (engine) {
+ engine_interface = engine->new_queued_interface();
+ engine->activate();
+ }
/* Connect to remote engine */
@@ -173,12 +178,12 @@ main(int argc, char** argv)
bool ran_gui = false;
if (args.gui_given) {
gui_module = Ingen::Shared::load_module("ingen_gui");
- void (*run)(int, char**) = NULL;
+ void (*run)(int, char**, SharedPtr<Ingen::Engine>, SharedPtr<Shared::EngineInterface>) = NULL;
bool found = gui_module->get_symbol("run", (void*&)run);
if (found) {
ran_gui = true;
- run(argc, argv);
+ run(argc, argv, engine, engine_interface);
} else {
cerr << "Unable to find GUI module, GUI not loaded." << endl;
cerr << "Try running ingen_dev or setting INGEN_MODULE_PATH." << endl;