summaryrefslogtreecommitdiffstats
path: root/src/Patchage.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-22 03:26:33 +0000
committerDavid Robillard <d@drobilla.net>2008-08-22 03:26:33 +0000
commit4637ceb876904731d2628563e96a89961f9b7781 (patch)
treeb20bd41c8fcdee1b8a5e76a0aa4a3ca213f82473 /src/Patchage.cpp
parent503944e72ce146e5bed2556e7b2caa5a41edd7ea (diff)
downloadpatchage-4637ceb876904731d2628563e96a89961f9b7781.tar.gz
patchage-4637ceb876904731d2628563e96a89961f9b7781.tar.bz2
patchage-4637ceb876904731d2628563e96a89961f9b7781.zip
Lash D-Bus support and projects list from LADI Patchage, with improvements/cleanup/sanification/etc.
Remove liblash stuff (meh, what the hell... here's to new beginnings). Enable/disable/hide/etc patchage widgets better based on available (compiled in) functionality. git-svn-id: http://svn.drobilla.net/lad/patchage@1462 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Patchage.cpp')
-rw-r--r--src/Patchage.cpp208
1 files changed, 88 insertions, 120 deletions
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index caf0c10..8b222db 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -32,7 +32,6 @@
#include "JackDriver.hpp"
#include <jack/statistics.h>
#endif
-#include "JackSettingsDialog.hpp"
#include "Patchage.hpp"
#include "PatchageCanvas.hpp"
#include "PatchageEvent.hpp"
@@ -40,10 +39,16 @@
#ifdef HAVE_ALSA
#include "AlsaDriver.hpp"
#endif
-#ifdef HAVE_LASH
-#include "LashDriver.hpp"
+#ifdef HAVE_DBUS
+#include "DBus.hpp"
+#include "LashProxy.hpp"
+#include "LoadProjectDialog.hpp"
+#include "ProjectList.hpp"
+#include "Session.hpp"
#endif
+#define LOG_TO_STATUS 1
+
using namespace std;
/* Gtk helpers (resize combo boxes) */
@@ -77,50 +82,48 @@ gtkmm_set_width_for_given_text (Gtk::Widget &w, const gchar *text,
/* end Gtk helpers */
-#define INIT_WIDGET(x) x(xml, ((const char*)#x) + 1)
+#define INIT_WIDGET(x) x(_xml, ((const char*)#x) + 1)
Patchage::Patchage(int argc, char** argv)
- : xml(GladeFile::open("patchage"))
-#ifdef HAVE_LASH
- , _lash_driver(NULL)
- , INIT_WIDGET(_menu_open_session)
- , INIT_WIDGET(_menu_save_session)
- , INIT_WIDGET(_menu_save_session_as)
- , INIT_WIDGET(_menu_close_session)
- , INIT_WIDGET(_menu_lash_connect)
- , INIT_WIDGET(_menu_lash_disconnect)
+ : _xml(GladeFile::open("patchage"))
+#ifdef HAVE_DBUS
+ , _lash_proxy(NULL)
+ , _dbus(NULL)
+ , _project_list(NULL)
+ , _session(NULL)
#endif
#ifdef HAVE_ALSA
, _alsa_driver(NULL)
, _alsa_driver_autoattach(true)
- , INIT_WIDGET(_menu_alsa_connect)
- , INIT_WIDGET(_menu_alsa_disconnect)
#endif
, _jack_driver(NULL)
, _state_manager(NULL)
, _attach(true)
, _refresh(false)
, _enable_refresh(true)
- , _jack_settings_dialog(NULL)
, INIT_WIDGET(_about_win)
, INIT_WIDGET(_buffer_size_combo)
, INIT_WIDGET(_clear_load_but)
, INIT_WIDGET(_main_scrolledwin)
, INIT_WIDGET(_main_win)
, INIT_WIDGET(_main_xrun_progress)
+ , INIT_WIDGET(_menu_alsa_connect)
+ , INIT_WIDGET(_menu_alsa_disconnect)
, INIT_WIDGET(_menu_file_quit)
, INIT_WIDGET(_menu_help_about)
, INIT_WIDGET(_menu_jack_connect)
, INIT_WIDGET(_menu_jack_disconnect)
- , INIT_WIDGET(_menu_jack_settings)
+ , INIT_WIDGET(_menu_open_session)
, INIT_WIDGET(_menu_store_positions)
, INIT_WIDGET(_menu_view_arrange)
, INIT_WIDGET(_menu_view_messages)
+ , INIT_WIDGET(_menu_view_projects)
, INIT_WIDGET(_menu_view_refresh)
, INIT_WIDGET(_menu_view_toolbar)
- , INIT_WIDGET(_messages_win)
, INIT_WIDGET(_messages_clear_but)
, INIT_WIDGET(_messages_close_but)
+ , INIT_WIDGET(_messages_win)
+ , INIT_WIDGET(_project_list_viewport)
, INIT_WIDGET(_sample_rate_label)
, INIT_WIDGET(_status_text)
, INIT_WIDGET(_toolbar)
@@ -146,8 +149,6 @@ Patchage::Patchage(int argc, char** argv)
argc--;
}
- xml->get_widget_derived("jack_settings_win", _jack_settings_dialog);
-
Glib::set_application_name("Patchage");
_about_win->property_program_name() = "Patchage";
_about_win->property_logo_icon_name() = "patchage";
@@ -173,22 +174,12 @@ Patchage::Patchage(int argc, char** argv)
sigc::mem_fun(this, &Patchage::zoom), 1.0));
_zoom_full_but->signal_clicked().connect(
sigc::mem_fun(_canvas.get(), &PatchageCanvas::zoom_full));
- _menu_jack_settings->signal_activate().connect(sigc::hide_return(
- sigc::mem_fun(_jack_settings_dialog, &JackSettingsDialog::run)));
-#ifdef HAVE_LASH
+#ifdef HAVE_DBUS
_menu_open_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_open_session));
- _menu_save_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_save_session));
- _menu_save_session_as->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_save_session_as));
- _menu_close_session->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_close_session));
- _menu_lash_connect->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_lash_connect));
- _menu_lash_disconnect->signal_activate().connect(
- sigc::mem_fun(this, &Patchage::menu_lash_disconnect));
+ sigc::mem_fun(this, &Patchage::show_load_project_dialog));
+#else
+ _menu_open_session->set_sensitive(false);
#endif
#ifdef HAVE_ALSA
@@ -196,6 +187,9 @@ Patchage::Patchage(int argc, char** argv)
sigc::mem_fun(this, &Patchage::menu_alsa_connect));
_menu_alsa_disconnect->signal_activate().connect(
sigc::mem_fun(this, &Patchage::menu_alsa_disconnect));
+#else
+ _menu_alsa_connect->set_sensitive(false);
+ _menu_alsa_disconnect->set_sensitive(false);
#endif
_menu_store_positions->signal_activate().connect(
@@ -210,6 +204,8 @@ Patchage::Patchage(int argc, char** argv)
sigc::mem_fun(this, &Patchage::on_view_toolbar));
_menu_view_messages->signal_toggled().connect(
sigc::mem_fun(this, &Patchage::on_show_messages));
+ _menu_view_projects->signal_toggled().connect(
+ sigc::mem_fun(this, &Patchage::on_show_projects));
_menu_help_about->signal_activate().connect(
sigc::mem_fun(this, &Patchage::on_help_about));
@@ -249,8 +245,13 @@ Patchage::Patchage(int argc, char** argv)
_alsa_driver = new AlsaDriver(this);
#endif
-#ifdef HAVE_LASH
- _lash_driver = new LashDriver(this, argc, argv);
+#ifdef HAVE_DBUS
+ _dbus = new DBus(this);
+ _session = new Session();
+ _project_list = new ProjectList(this, _session);
+ _lash_proxy = new LashProxy(this, _session);
+#else
+ _project_list_viewport->hide();
#endif
connect_widgets();
@@ -272,14 +273,14 @@ Patchage::~Patchage()
#ifdef HAVE_ALSA
delete _alsa_driver;
#endif
-#ifdef HAVE_LASH
- delete _lash_driver;
+#ifdef HAVE_DBUS
+ delete _lash_proxy;
#endif
delete _state_manager;
-
+
_about_win.destroy();
_messages_win.destroy();
- _main_win.destroy();
+ //_main_win.destroy();
}
@@ -292,9 +293,6 @@ Patchage::attach()
_jack_driver->attach(true);
#endif
-#ifdef HAVE_LASH
- _lash_driver->attach(true);
-#endif
#ifdef HAVE_ALSA
if (_alsa_driver_autoattach)
_alsa_driver->attach();
@@ -333,11 +331,6 @@ Patchage::idle_callback()
}
#endif
-#ifdef HAVE_LASH
- if (_lash_driver->is_attached())
- _lash_driver->process_events(this);
-#endif
-
// Do a full refresh (ie user clicked refresh)
if (_refresh) {
refresh();
@@ -451,7 +444,31 @@ Patchage::clear_load()
void
-Patchage::status_message(const string& msg)
+Patchage::error_msg(const std::string& msg)
+{
+#if defined(LOG_TO_STATUS)
+ status_msg(msg);
+#endif
+#if defined(LOG_TO_STD)
+ cerr << msg << endl;
+#endif
+}
+
+
+void
+Patchage::info_msg(const std::string& msg)
+{
+#if defined(LOG_TO_STATUS)
+ status_msg(msg);
+#endif
+#if defined(LOG_TO_STD)
+ cerr << msg << endl;
+#endif
+}
+
+
+void
+Patchage::status_msg(const string& msg)
{
if (_status_text->get_buffer()->size() > 0)
_status_text->get_buffer()->insert(_status_text->get_buffer()->end(), "\n");
@@ -479,18 +496,6 @@ Patchage::update_state()
void
Patchage::connect_widgets()
{
-#ifdef HAVE_LASH
- _lash_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_lash_connect, &Gtk::MenuItem::set_sensitive), false));
- _lash_driver->signal_attached.connect(sigc::bind(
- sigc::mem_fun(*_menu_lash_disconnect, &Gtk::MenuItem::set_sensitive), true));
-
- _lash_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_lash_connect, &Gtk::MenuItem::set_sensitive), true));
- _lash_driver->signal_detached.connect(sigc::bind(
- sigc::mem_fun(*_menu_lash_disconnect, &Gtk::MenuItem::set_sensitive), false));
-#endif
-
#if defined(HAVE_JACK) || defined(HAVE_JACK_DBUS)
_jack_driver->signal_attached.connect(
sigc::mem_fun(this, &Patchage::update_toolbar));
@@ -520,72 +525,25 @@ Patchage::connect_widgets()
#endif
}
-
-#ifdef HAVE_LASH
+#ifdef HAVE_DBUS
void
-Patchage::menu_open_session()
+Patchage::show_load_project_dialog()
{
- Gtk::FileChooserDialog dialog(*_main_win, "Open LASH Session",
- Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ std::list<ProjectInfo> projects;
+ _lash_proxy->get_available_projects(projects);
- dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
-
- const int result = dialog.run();
-
- if (result == Gtk::RESPONSE_OK) {
- _lash_driver->restore_project(dialog.get_filename());
- }
-}
-
-
-void
-Patchage::menu_save_session()
-{
- if (_lash_driver)
- _lash_driver->save_project();
-}
-
-
-void
-Patchage::menu_save_session_as()
-{
- if (!_lash_driver)
- return;
-
- Gtk::FileChooserDialog dialog(*_main_win, "Save LASH Session",
- Gtk::FILE_CHOOSER_ACTION_SAVE);
-
- dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
-
- const int result = dialog.run();
-
- if (result == Gtk::RESPONSE_OK) {
- _lash_driver->set_project_directory(dialog.get_filename());
- _lash_driver->save_project();
- }
-}
-
-
-void
-Patchage::menu_close_session()
-{
- _lash_driver->close_project();
-}
-
-
-void
-Patchage::menu_lash_connect()
-{
- _lash_driver->attach(true);
+ LoadProjectDialog dialog(this);
+ dialog.run(projects);
}
+#endif
-
+#ifdef HAVE_DBUS
void
-Patchage::menu_lash_disconnect()
+Patchage::set_lash_available(bool available)
{
- _lash_driver->detach();
+ _project_list->set_lash_available(available);
+ if (!available)
+ _session->clear();
}
#endif
@@ -670,6 +628,16 @@ Patchage::on_show_messages()
_messages_win->hide();
}
+
+void
+Patchage::on_show_projects()
+{
+ if (_menu_view_projects->get_active())
+ _project_list_viewport->show();
+ else
+ _project_list_viewport->hide();
+}
+
void
Patchage::on_store_positions()