summaryrefslogtreecommitdiffstats
path: root/src/libs/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/gui')
-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
4 files changed, 72 insertions, 38 deletions
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();