From 45eae6d2d3729876b898e5964829771985eaf9f7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Jun 2006 21:21:44 +0000 Subject: Connect window revamp git-svn-id: http://svn.drobilla.net/lad/grauph@45 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/gtk/ConnectWindow.cpp | 97 ++++--- src/progs/gtk/ConnectWindow.h | 17 +- src/progs/gtk/om_gtk.glade | 395 +++++++---------------------- src/progs/gtk/om_gtk.glade.bak | 541 ++++++++++------------------------------ 4 files changed, 289 insertions(+), 761 deletions(-) (limited to 'src') diff --git a/src/progs/gtk/ConnectWindow.cpp b/src/progs/gtk/ConnectWindow.cpp index deb2c134..fd19fc64 100644 --- a/src/progs/gtk/ConnectWindow.cpp +++ b/src/progs/gtk/ConnectWindow.cpp @@ -34,21 +34,23 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("connect_icon", _icon); - xml->get_widget("connect_progress_bar", _progress_bar); - xml->get_widget("connect_label", _label); - xml->get_widget("connect_url_entry", _url_entry); - xml->get_widget("connect_connect_button", _connect_button); - xml->get_widget("connect_port_spinbutton", _port_spinbutton); - xml->get_widget("connect_launch_button", _launch_button); - xml->get_widget("connect_spawn_internal_button", _spawn_internal_button); - xml->get_widget("connect_disconnect_button", _disconnect_button); - xml->get_widget("connect_quit_button", _quit_button); + xml->get_widget("connect_icon", _icon); + xml->get_widget("connect_progress_bar", _progress_bar); + xml->get_widget("connect_progress_label", _progress_label); + xml->get_widget("connect_server_radiobutton", _server_radio); + xml->get_widget("connect_url_entry", _url_entry); + xml->get_widget("connect_launch_radiobutton", _launch_radio); + xml->get_widget("connect_port_spinbutton", _port_spinbutton); + xml->get_widget("connect_internal_radiobutton", _internal_radio); + xml->get_widget("connect_disconnect_button", _disconnect_button); + xml->get_widget("connect_connect_button", _connect_button); + xml->get_widget("connect_quit_button", _quit_button); - _connect_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::connect)); - _launch_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::launch)); - _spawn_internal_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::spawn_internal)); + _server_radio->signal_toggled().connect(sigc::mem_fun(this, &ConnectWindow::server_toggled)); + _launch_radio->signal_toggled().connect(sigc::mem_fun(this, &ConnectWindow::launch_toggled)); + _internal_radio->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::internal_toggled)); _disconnect_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::disconnect)); + _connect_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::connect)); _quit_button->signal_clicked().connect(sigc::mem_fun(this, &ConnectWindow::quit)); } @@ -65,9 +67,29 @@ ConnectWindow::start(CountedPtr client) void ConnectWindow::connect() { - Controller::instance().set_engine_url(_url_entry->get_text()); - Glib::signal_timeout().connect( - sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); + if (_server_radio->get_active()) { + Controller::instance().set_engine_url(_url_entry->get_text()); + Glib::signal_timeout().connect( + sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); + + } else if (_launch_radio->get_active()) { + int port = _port_spinbutton->get_value_as_int(); + char port_str[6]; + snprintf(port_str, 6, "%u", port); + const string port_arg = string("--port=").append(port_str); + Controller::instance().set_engine_url( + string("osc.udp://localhost:").append(port_str)); + + if (fork() == 0) { // child + cerr << "Executing 'om " << port_arg << "' ..." << endl; + execlp("om", port_arg.c_str(), 0); + } else { + Glib::signal_timeout().connect( + sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); + } + } + + _connect_button->set_sensitive(false); } @@ -97,22 +119,27 @@ ConnectWindow::quit() void -ConnectWindow::launch() +ConnectWindow::server_toggled() { - if (fork() == 0) { - //cerr << "Launching engine.."; - execlp("om", NULL); - - Glib::signal_timeout().connect( - sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100); - } + _url_entry->set_sensitive(true); + _port_spinbutton->set_sensitive(false); +} + + +void +ConnectWindow::launch_toggled() +{ + _url_entry->set_sensitive(false); + _port_spinbutton->set_sensitive(true); } void -ConnectWindow::spawn_internal() +ConnectWindow::internal_toggled() { // Not quite yet... + _url_entry->set_sensitive(false); + _port_spinbutton->set_sensitive(false); } @@ -134,7 +161,7 @@ ConnectWindow::gtk_callback() if (stage == 0) { // FIXME //assert(!Controller::instance().is_attached()); - _label->set_text(string("Connecting to engine at ").append( + _progress_label->set_text(string("Connecting to engine at ").append( Controller::instance().engine_url()).append("...")); present(); Controller::instance().attach(); @@ -152,7 +179,7 @@ ConnectWindow::gtk_callback() } } } else if (stage == 2) { - _label->set_text(string("Registering as client...")); + _progress_label->set_text(string("Registering as client...")); //Controller::instance().register_client(Controller::instance().client_hooks()); // FIXME //auto_ptr client(new ThreadedSigClientInterface(); @@ -169,13 +196,13 @@ ConnectWindow::gtk_callback() sigc::mem_fun((ThreadedSigClientInterface*)_client, &ThreadedSigClientInterface::emit_signals), 5, G_PRIORITY_DEFAULT_IDLE);*/ - _label->set_text(string("Requesting plugins...")); + _progress_label->set_text(string("Requesting plugins...")); Controller::instance().request_plugins(); ++stage; } else if (stage == 4) { // Wait for first plugins message if (Store::instance().plugins().size() > 0) { - _label->set_text(string("Receiving plugins...")); + _progress_label->set_text(string("Receiving plugins...")); ++stage; } } else if (stage == 5) { @@ -192,7 +219,7 @@ ConnectWindow::gtk_callback() ++stage; //} } else if (stage == 6) { - _label->set_text(string("Waiting for root patch...")); + _progress_label->set_text(string("Waiting for root patch...")); Controller::instance().request_all_objects(); ++stage; } else if (stage == 7) { @@ -204,10 +231,12 @@ ConnectWindow::gtk_callback() ++stage; } } else if (stage == 8) { - _label->set_text(string("Connected to engine at ").append( + _progress_label->set_text(string("Connected to engine at ").append( Controller::instance().engine_url())); + ++stage; + } else if (stage == 9) { stage = -1; - hide(); // FIXME: actually destroy window to save mem? + hide(); } if (stage != 5) // yeah, ew @@ -219,8 +248,8 @@ ConnectWindow::gtk_callback() _url_entry->set_sensitive(false); _connect_button->set_sensitive(false); _port_spinbutton->set_sensitive(false); - _launch_button->set_sensitive(false); - _spawn_internal_button->set_sensitive(false); + _launch_radio->set_sensitive(false); + _internal_radio->set_sensitive(false); return false; // deregister this callback } else { return true; diff --git a/src/progs/gtk/ConnectWindow.h b/src/progs/gtk/ConnectWindow.h index 7f405097..cc8b1c79 100644 --- a/src/progs/gtk/ConnectWindow.h +++ b/src/progs/gtk/ConnectWindow.h @@ -43,24 +43,27 @@ public: void start(CountedPtr client); private: - void connect(); + void server_toggled(); + void launch_toggled(); + void internal_toggled(); + void disconnect(); + void connect(); void quit(); - void launch(); - void spawn_internal(); bool gtk_callback(); CountedPtr _client; Gtk::Image* _icon; Gtk::ProgressBar* _progress_bar; - Gtk::Label* _label; + Gtk::Label* _progress_label; Gtk::Entry* _url_entry; - Gtk::Button* _connect_button; + Gtk::RadioButton* _server_radio; Gtk::SpinButton* _port_spinbutton; - Gtk::Button* _launch_button; - Gtk::Button* _spawn_internal_button; + Gtk::RadioButton* _launch_radio; + Gtk::RadioButton* _internal_radio; Gtk::Button* _disconnect_button; + Gtk::Button* _connect_button; Gtk::Button* _quit_button; }; diff --git a/src/progs/gtk/om_gtk.glade b/src/progs/gtk/om_gtk.glade index 16e15a2e..584336a9 100644 --- a/src/progs/gtk/om_gtk.glade +++ b/src/progs/gtk/om_gtk.glade @@ -3127,6 +3127,19 @@ Contributors: True GTK_BUTTONBOX_END + + + True + True + True + gtk-quit + True + GTK_RELIEF_NORMAL + True + 0 + + + True @@ -3142,11 +3155,12 @@ Contributors: - + True True + True True - gtk-quit + gtk-connect True GTK_RELIEF_NORMAL True @@ -3215,7 +3229,7 @@ Contributors: - + True Not Connected False @@ -3249,7 +3263,7 @@ Contributors: 0 True - True + False @@ -3273,122 +3287,16 @@ Contributors: 8 0 - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-execute - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Launch Server - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 1 - 2 - 1 - 2 - fill - - - - True False 0 - - - True - Port: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - - True + False True 1 0 @@ -3406,8 +3314,8 @@ Contributors: - 0 - 1 + 1 + 2 1 2 8 @@ -3416,161 +3324,57 @@ Contributors: - + True - False - True - GTK_RELIEF_NORMAL - True + False + 0 - + True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-execute - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Spawn _Internal Engine - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - + True + True + True + 0 + osc.udp://localhost:16180 + True + * + True + 28 + + 0 + True + True + 1 2 - 2 - 3 + 0 + 1 + 8 fill - + fill - + True True + Connect to running server at: + True GTK_RELIEF_NORMAL True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-connect - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Connect to Server - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - + False + False + True - 1 - 2 + 0 + 1 0 1 fill @@ -3579,78 +3383,62 @@ Contributors: - + True - False - 0 - - - - True - URL: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - + True + Launch and connect to server on port: + True + GTK_RELIEF_NORMAL + True + False + False + True + connect_server_radiobutton + + + 0 + 1 + 1 + 2 + fill + + + - - - True - True - True - True - 0 - osc.udp://localhost:16180 - True - * - False - 28 - - - 0 - False - False - - + + + True + False + True + Use internal engine + True + GTK_RELIEF_NORMAL + True + False + False + True + connect_server_radiobutton 0 1 - 0 - 1 - 8 + 2 + 3 fill - fill + True - False - This executable does not include an engine + False False GTK_JUSTIFY_LEFT False False - 1 + 0 0.5 0 0 @@ -3660,11 +3448,10 @@ Contributors: 0 - 0 - 1 + 1 + 2 2 3 - 8 fill diff --git a/src/progs/gtk/om_gtk.glade.bak b/src/progs/gtk/om_gtk.glade.bak index ac12bb1e..e97cb4bd 100644 --- a/src/progs/gtk/om_gtk.glade.bak +++ b/src/progs/gtk/om_gtk.glade.bak @@ -52,7 +52,7 @@ - + True gtk-open 1 @@ -107,7 +107,7 @@ - + True gtk-preferences 1 @@ -190,7 +190,7 @@ - + True gtk-preferences 1 @@ -232,7 +232,7 @@ - + True gtk-delete 1 @@ -250,113 +250,8 @@ - + True - _Add - True - - - - - - - - True - Load a plugin as a child of this patch - _Plugin... - True - - - - - True - gtk-execute - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - Load a patch as a child of this patch - _Patch From File... - True - - - - - - True - gtk-open - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - Create a new (empty) patch as a child of this patch - _New Patch... - True - - - - - - True - gtk-new - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - - - - - - True - False - Using this menu will place items randomly - right click! - Right click on canvas to manually place an object - True - - - - - True - gtk-info - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - @@ -380,7 +275,7 @@ - + True gtk-connect 1 @@ -403,7 +298,7 @@ - + True gtk-index 1 @@ -426,7 +321,7 @@ - + True gtk-dialog-error 1 @@ -453,6 +348,33 @@ + + + True + Right-click the canvas to add objects + True + + + + + True + gtk-info + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + + + True @@ -3219,6 +3141,20 @@ Contributors: + + + True + True + True + True + gtk-connect + True + GTK_RELIEF_NORMAL + True + -6 + + + True @@ -3228,7 +3164,7 @@ Contributors: True GTK_RELIEF_NORMAL True - -6 + 0 @@ -3293,7 +3229,7 @@ Contributors: - + True Not Connected False @@ -3327,7 +3263,7 @@ Contributors: 0 True - True + False @@ -3351,122 +3287,16 @@ Contributors: 8 0 - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-execute - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Launch Server - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 1 - 2 - 1 - 2 - fill - - - - True False 0 - - - True - Port: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - - True + False True 1 0 @@ -3484,8 +3314,8 @@ Contributors: - 0 - 1 + 1 + 2 1 2 8 @@ -3494,161 +3324,57 @@ Contributors: - + True - False - True - GTK_RELIEF_NORMAL - True + False + 0 - + True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-execute - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Spawn _Internal Engine - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - + True + True + True + 0 + osc.udp://localhost:16180 + True + * + True + 28 + + 0 + True + True + 1 2 - 2 - 3 + 0 + 1 + 8 fill - + fill - + True True + Connect to running server at: + True GTK_RELIEF_NORMAL True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-connect - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Connect to Server - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - + False + False + True - 1 - 2 + 0 + 1 0 1 fill @@ -3657,78 +3383,62 @@ Contributors: - + True - False - 0 - - - - True - URL: - False - False - GTK_JUSTIFY_LEFT - False - False - 1 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - + True + Launch and connect to server on port: + True + GTK_RELIEF_NORMAL + True + False + False + True + connect_server_radiobutton + + + 0 + 1 + 1 + 2 + fill + + + - - - True - True - True - True - 0 - osc.udp://localhost:16180 - True - * - False - 28 - - - 0 - False - False - - + + + True + False + True + Use internal engine + True + GTK_RELIEF_NORMAL + True + False + False + True + connect_server_radiobutton 0 1 - 0 - 1 - 8 + 2 + 3 fill - fill + True - False - This executable does not include an engine + False False GTK_JUSTIFY_LEFT False False - 1 + 0 0.5 0 0 @@ -3738,11 +3448,10 @@ Contributors: 0 - 0 - 1 + 1 + 2 2 3 - 8 fill -- cgit v1.2.1