summaryrefslogtreecommitdiffstats
path: root/src/progs/ingenuity
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-05-01 05:53:04 +0000
committerDavid Robillard <d@drobilla.net>2007-05-01 05:53:04 +0000
commite19f2f14e830b016c27fc1369a34055a1764a0f5 (patch)
treef93446edfe8bafc692f7adf9355db43d6cdce0f9 /src/progs/ingenuity
parent3f94f9ccf13d08b8bf7acd786e0b894f01fb5175 (diff)
downloadingen-e19f2f14e830b016c27fc1369a34055a1764a0f5.tar.gz
ingen-e19f2f14e830b016c27fc1369a34055a1764a0f5.tar.bz2
ingen-e19f2f14e830b016c27fc1369a34055a1764a0f5.zip
GUI cleanups.
Fixed cancelling current connection attempt in engine window (w/ disconnect button). Automatically attempt to connect to running local server on the default port. git-svn-id: http://svn.drobilla.net/lad/ingen@488 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs/ingenuity')
-rw-r--r--src/progs/ingenuity/App.cpp16
-rw-r--r--src/progs/ingenuity/ConnectWindow.cpp80
-rw-r--r--src/progs/ingenuity/ConnectWindow.h2
-rw-r--r--src/progs/ingenuity/ingenuity.glade44
4 files changed, 83 insertions, 59 deletions
diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp
index e1e4912d..8ffcd710 100644
--- a/src/progs/ingenuity/App.cpp
+++ b/src/progs/ingenuity/App.cpp
@@ -120,13 +120,15 @@ App::attach(const SharedPtr<ModelEngineInterface>& engine, const SharedPtr<SigCl
void
App::detach()
{
- _window_factory->clear();
- _store->clear();
-
- _loader.reset();
- _store.reset();
- _client.reset();
- _engine.reset();
+ if (_engine) {
+ _window_factory->clear();
+ _store->clear();
+
+ _loader.reset();
+ _store.reset();
+ _client.reset();
+ _engine.reset();
+ }
}
diff --git a/src/progs/ingenuity/ConnectWindow.cpp b/src/progs/ingenuity/ConnectWindow.cpp
index ac26c6fa..9fe45dfa 100644
--- a/src/progs/ingenuity/ConnectWindow.cpp
+++ b/src/progs/ingenuity/ConnectWindow.cpp
@@ -74,10 +74,11 @@ struct QueuedModelEngineInterface : public QueuedEngineInterface, public ModelEn
ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
-: Gtk::Dialog(cobject)
-, _mode(CONNECT_REMOTE)
-, _ping_id(-1)
-, _attached(false)
+ : Gtk::Dialog(cobject)
+ , _mode(CONNECT_REMOTE)
+ , _ping_id(-1)
+ , _attached(false)
+ , _connect_stage(0)
{
xml->get_widget("connect_icon", _icon);
xml->get_widget("connect_progress_bar", _progress_bar);
@@ -106,6 +107,7 @@ ConnectWindow::start()
resize(100, 100);
init();
show();
+ connect();
}
@@ -143,6 +145,9 @@ ConnectWindow::connect()
assert(!App::instance().client());
_connect_button->set_sensitive(false);
+ _disconnect_button->set_sensitive(true);
+
+ _connect_stage = 0;
if (_mode == CONNECT_REMOTE) {
SharedPtr<ModelEngineInterface> engine(
@@ -215,6 +220,7 @@ ConnectWindow::connect()
void
ConnectWindow::disconnect()
{
+ _connect_stage = -1;
_attached = false;
_progress_bar->set_fraction(0.0);
@@ -224,6 +230,9 @@ ConnectWindow::disconnect()
App::instance().detach();
init();
+
+ _connect_button->set_sensitive(true);
+ _disconnect_button->set_sensitive(false);
}
@@ -284,10 +293,8 @@ ConnectWindow::gtk_callback()
gettimeofday(&now, NULL);
static timeval last = now;
- static int stage = 0;
-
/* Connecting to engine */
- if (stage == 0) {
+ if (_connect_stage == 0) {
assert(!_attached);
assert(App::instance().engine());
@@ -306,13 +313,13 @@ ConnectWindow::gtk_callback()
App::instance().engine()->set_next_response_id(_ping_id);
App::instance().engine()->ping();
- ++stage;
+ ++_connect_stage;
- } else if (stage == 1) {
+ } else if (_connect_stage == 1) {
if (_attached) {
App::instance().engine()->activate();
- ++stage;
+ ++_connect_stage;
} else {
const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f +
(now.tv_usec - last.tv_usec) * 0.001f;
@@ -322,15 +329,15 @@ ConnectWindow::gtk_callback()
last = now;
}
}
- } else if (stage == 2) {
+ } else if (_connect_stage == 2) {
_progress_label->set_text(string("Registering as client..."));
//App::instance().engine()->register_client(App::instance().engine()->client_hooks());
// FIXME
//auto_ptr<ClientInterface> client(new ThreadedSigClientInterface();
App::instance().engine()->register_client(ClientKey(), App::instance().client());
App::instance().engine()->load_plugins();
- ++stage;
- } else if (stage == 3) {
+ ++_connect_stage;
+ } else if (_connect_stage == 3) {
// Register idle callback to process events and whatnot
// (Gtk refreshes at priority G_PRIORITY_HIGH_IDLE+20)
/*Glib::signal_timeout().connect(
@@ -342,14 +349,14 @@ ConnectWindow::gtk_callback()
_progress_label->set_text(string("Requesting plugins..."));
App::instance().engine()->request_plugins();
- ++stage;
- } else if (stage == 4) {
+ ++_connect_stage;
+ } else if (_connect_stage == 4) {
// Wait for first plugins message
if (App::instance().store()->plugins().size() > 0) {
_progress_label->set_text(string("Receiving plugins..."));
- ++stage;
+ ++_connect_stage;
}
- } else if (stage == 5) {
+ } else if (_connect_stage == 5) {
// FIXME
/*if (App::instance().store().plugins().size() < _client->num_plugins()) {
static char buf[32];
@@ -360,31 +367,26 @@ ConnectWindow::gtk_callback()
App::instance().store().plugins().size() / (double)_client->num_plugins());
} else {*/
_progress_bar->set_text("");
- ++stage;
+ ++_connect_stage;
//}
- } else if (stage == 6) {
+ } else if (_connect_stage == 6) {
_progress_label->set_text(string("Waiting for root patch..."));
App::instance().engine()->request_all_objects();
- ++stage;
- } else if (stage == 7) {
+ ++_connect_stage;
+ } else if (_connect_stage == 7) {
if (App::instance().store()->objects().size() > 0) {
SharedPtr<PatchModel> root = PtrCast<PatchModel>(App::instance().store()->object("/"));
assert(root);
App::instance().window_factory()->present_patch(root);
- ++stage;
+ ++_connect_stage;
}
- } else if (stage == 8) {
+ } else if (_connect_stage == 8) {
_progress_label->set_text("Connected to engine");
- ++stage;
- } else if (stage == 9) {
- stage = -1;
+ ++_connect_stage;
+ } else if (_connect_stage == 9) {
+ ++_connect_stage;
hide();
- }
-
- if (stage != 5) // yeah, ew
- _progress_bar->pulse();
-
- if (stage == -1) { // finished connecting
+ } 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);
@@ -393,7 +395,19 @@ ConnectWindow::gtk_callback()
_port_spinbutton->set_sensitive(false);
_launch_radio->set_sensitive(false);
_internal_radio->set_sensitive(false);
- stage = 0; // set ourselves up for next time (if there is one)
+ _connect_stage = 0; // set ourselves up for next time (if there is one)
+ return false; // deregister this callback
+ }
+
+ if (_connect_stage != 5) // yeah, ew
+ _progress_bar->pulse();
+
+ if (_connect_stage == -1) { // we were cancelled
+ _icon->set(Gtk::Stock::DISCONNECT, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ _progress_bar->set_fraction(0.0);
+ _connect_button->set_sensitive(true);
+ _disconnect_button->set_sensitive(false);
+ _connect_stage = 0; // set ourselves up for next time (if there is one)
return false; // deregister this callback
} else {
return true;
diff --git a/src/progs/ingenuity/ConnectWindow.h b/src/progs/ingenuity/ConnectWindow.h
index 0aa03313..7e137066 100644
--- a/src/progs/ingenuity/ConnectWindow.h
+++ b/src/progs/ingenuity/ConnectWindow.h
@@ -63,6 +63,8 @@ private:
Mode _mode;
int32_t _ping_id;
bool _attached;
+
+ int _connect_stage;
Gtk::Image* _icon;
Gtk::ProgressBar* _progress_bar;
diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade
index 12f292e7..6eaf300e 100644
--- a/src/progs/ingenuity/ingenuity.glade
+++ b/src/progs/ingenuity/ingenuity.glade
@@ -3,7 +3,7 @@
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkWindow" id="patch_win">
- <property name="title" translatable="yes">Ingen</property>
+ <property name="title" translatable="yes">Ingenuity</property>
<property name="default_width">640</property>
<property name="default_height">480</property>
<property name="icon">ingen.svg</property>
@@ -164,6 +164,21 @@
<child>
<widget class="GtkMenu" id="edit2_menu">
<child>
+ <widget class="GtkImageMenuItem" id="patch_clear_menuitem">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Remove all objects from patch</property>
+ <property name="label">gtk-clear</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="on_patch_clear_menuitem_activate"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkSeparatorMenuItem" id="separator99">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+ <child>
<widget class="GtkImageMenuItem" id="patch_cut_menuitem">
<property name="visible">True</property>
<property name="sensitive">False</property>
@@ -277,16 +292,6 @@
</widget>
</child>
<child>
- <widget class="GtkImageMenuItem" id="patch_clear_menuitem">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Remove all objects from patch</property>
- <property name="label">gtk-clear</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_patch_clear_menuitem_activate"/>
- </widget>
- </child>
- <child>
<widget class="GtkImageMenuItem" id="patch_destroy_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Destoy this patch (remove it from the engine)</property>
@@ -325,7 +330,7 @@
<child internal-child="image">
<widget class="GtkImage" id="image2132">
<property name="visible">True</property>
- <property name="stock">gtk-connect</property>
+ <property name="stock">gtk-execute</property>
<property name="icon_size">1</property>
</widget>
</child>
@@ -359,7 +364,7 @@
<child internal-child="image">
<widget class="GtkImage" id="image2134">
<property name="visible">True</property>
- <property name="stock">gtk-dialog-error</property>
+ <property name="stock">gtk-info</property>
<property name="icon_size">1</property>
</widget>
</child>
@@ -1595,7 +1600,7 @@
<property name="width_request">400</property>
<property name="height_request">180</property>
<property name="border_width">8</property>
- <property name="title" translatable="yes">Error Messages</property>
+ <property name="title" translatable="yes">Messages - Ingenuity</property>
<property name="icon">ingen.svg</property>
<child>
<widget class="GtkVBox" id="vbox12">
@@ -1662,7 +1667,7 @@
</widget>
<widget class="GtkWindow" id="config_win">
<property name="border_width">8</property>
- <property name="title" translatable="yes">Configuration</property>
+ <property name="title" translatable="yes">Configuration - Ingenuity</property>
<property name="icon">ingen.svg</property>
<child>
<widget class="GtkVBox" id="vbox13">
@@ -1989,7 +1994,7 @@
</widget>
<widget class="GtkWindow" id="node_properties_win">
<property name="border_width">6</property>
- <property name="title" translatable="yes">window1</property>
+ <property name="title" translatable="yes">Node Properties - Ingenuity</property>
<property name="icon">ingen.svg</property>
<child>
<widget class="GtkVBox" id="vbox17">
@@ -2213,7 +2218,7 @@ Contributors:
<property name="width_request">320</property>
<property name="height_request">340</property>
<property name="border_width">8</property>
- <property name="title" translatable="yes">Patches</property>
+ <property name="title" translatable="yes">Patches - Ingenuity</property>
<property name="icon">ingen.svg</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
@@ -2236,7 +2241,7 @@ Contributors:
</widget>
<widget class="GtkDialog" id="connect_win">
<property name="border_width">6</property>
- <property name="title" translatable="yes">Connect to Engine</property>
+ <property name="title" translatable="yes">Engine - Ingenuity</property>
<property name="resizable">False</property>
<property name="icon">ingen.svg</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
@@ -2922,9 +2927,10 @@ Thank you for contributing.</property>
<widget class="GtkDialog" id="port_properties_win">
<property name="border_width">8</property>
<property name="type">GTK_WINDOW_POPUP</property>
- <property name="title" translatable="yes">Port Properties</property>
+ <property name="title" translatable="yes">Port Properties - Ingenuity</property>
<property name="resizable">False</property>
<property name="window_position">GTK_WIN_POS_MOUSE</property>
+ <property name="destroy_with_parent">True</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">