summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-05-04 06:41:12 +0000
committerDavid Robillard <d@drobilla.net>2007-05-04 06:41:12 +0000
commitacdd2da8b42a590406aef07b8b63ba96b3e587a4 (patch)
treee0aa3e65fac15501a07cf074c522c16fd8156886 /src/libs
parent515a22e7f1175dfcc89657f805557348a93b3682 (diff)
downloadingen-acdd2da8b42a590406aef07b8b63ba96b3e587a4.tar.gz
ingen-acdd2da8b42a590406aef07b8b63ba96b3e587a4.tar.bz2
ingen-acdd2da8b42a590406aef07b8b63ba96b3e587a4.zip
Work on internal engine + GUI (still some problems).
git-svn-id: http://svn.drobilla.net/lad/ingen@498 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-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
6 files changed, 85 insertions, 38 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();