use session object and signals to route project added/closed notifications from lash proxy to gtk project list
This commit is contained in:
parent
70cb19e11b
commit
c1d00c4ad7
|
@ -36,6 +36,7 @@
|
|||
#include "StateManager.hpp"
|
||||
#include "lash_proxy.hpp"
|
||||
#include "project_list.hpp"
|
||||
#include "session.hpp"
|
||||
|
||||
//#define LOG_TO_STD
|
||||
#define LOG_TO_STATUS
|
||||
|
@ -208,9 +209,11 @@ Patchage::Patchage(int argc, char** argv)
|
|||
|
||||
_about_win->set_transient_for(*_main_win);
|
||||
|
||||
_project_list = new project_list(xml, this);
|
||||
_session = new session();
|
||||
|
||||
_lash = new lash_proxy(this);
|
||||
_project_list = new project_list(xml, this, _session);
|
||||
|
||||
_lash = new lash_proxy(this, _session);
|
||||
|
||||
_jack = new jack_proxy(this);
|
||||
|
||||
|
@ -236,6 +239,7 @@ Patchage::~Patchage()
|
|||
delete _jack;
|
||||
delete _lash;
|
||||
delete _project_list;
|
||||
delete _session;
|
||||
delete _state_manager;
|
||||
|
||||
_about_win.destroy();
|
||||
|
@ -626,20 +630,6 @@ Patchage::set_lash_availability(
|
|||
_project_list->set_lash_availability(lash_active);
|
||||
}
|
||||
|
||||
void
|
||||
Patchage::on_project_added(
|
||||
const std::string& project_name)
|
||||
{
|
||||
_project_list->project_added(project_name);
|
||||
}
|
||||
|
||||
void
|
||||
Patchage::on_project_closed(
|
||||
const std::string& project_name)
|
||||
{
|
||||
_project_list->project_closed(project_name);
|
||||
}
|
||||
|
||||
struct loadable_project_list_column_record : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
Gtk::TreeModelColumn<Glib::ustring> name;
|
||||
|
|
|
@ -36,6 +36,7 @@ class lash_proxy;
|
|||
class StateManager;
|
||||
class project_list;
|
||||
class PatchagePort;
|
||||
class session;
|
||||
|
||||
class Patchage {
|
||||
public:
|
||||
|
@ -87,14 +88,6 @@ public:
|
|||
|
||||
void set_lash_availability(bool lash_active);
|
||||
|
||||
void
|
||||
on_project_added(
|
||||
const std::string& project_name);
|
||||
|
||||
void
|
||||
on_project_closed(
|
||||
const std::string& project_name);
|
||||
|
||||
void load_project_ask();
|
||||
void load_project(const std::string& project_name);
|
||||
void save_all_projects();
|
||||
|
@ -138,6 +131,7 @@ protected:
|
|||
boost::shared_ptr<PatchageCanvas> _canvas;
|
||||
|
||||
jack_proxy* _jack;
|
||||
session * _session;
|
||||
lash_proxy * _lash;
|
||||
project_list * _project_list;
|
||||
StateManager* _state_manager;
|
||||
|
|
|
@ -20,7 +20,13 @@
|
|||
#define COMMON_HPP__AA9070A8_1E8C_4C6E_9769_395BF3D848C0__INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using namespace sigc;
|
||||
|
||||
#endif // #ifndef COMMON_HPP__AA9070A8_1E8C_4C6E_9769_395BF3D848C0__INCLUDED
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include "lash_proxy.hpp"
|
||||
#include "session.hpp"
|
||||
|
||||
#define LASH_SERVICE "org.nongnu.LASH"
|
||||
#define LASH_OBJECT "/"
|
||||
|
@ -26,8 +27,11 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
lash_proxy::lash_proxy(Patchage* app)
|
||||
lash_proxy::lash_proxy(
|
||||
Patchage* app,
|
||||
session * session_ptr)
|
||||
: _app(app)
|
||||
, _session_ptr(session_ptr)
|
||||
, _server_responding(false)
|
||||
{
|
||||
list<string> projects;
|
||||
|
@ -46,7 +50,7 @@ lash_proxy::lash_proxy(Patchage* app)
|
|||
|
||||
for (list<string>::iterator iter = projects.begin(); iter != projects.end(); iter++)
|
||||
{
|
||||
app->on_project_added(*iter);
|
||||
session_ptr->project_add(*iter);
|
||||
}
|
||||
|
||||
_app->set_lash_availability(_server_responding);
|
||||
|
@ -133,7 +137,7 @@ lash_proxy::dbus_message_hook(
|
|||
}
|
||||
|
||||
me->info_msg((string)"Project '" + project_name + "' added.");
|
||||
me->_app->on_project_added(project_name);
|
||||
me->_session_ptr->project_add(project_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
@ -151,7 +155,7 @@ lash_proxy::dbus_message_hook(
|
|||
}
|
||||
|
||||
me->info_msg((string)"Project '" + project_name + "' closed.");
|
||||
me->_app->on_project_closed(project_name);
|
||||
me->_session_ptr->project_close(project_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,14 @@ struct lash_project_info
|
|||
std::string comment;
|
||||
};
|
||||
|
||||
class session;
|
||||
|
||||
class lash_proxy
|
||||
{
|
||||
public:
|
||||
lash_proxy(Patchage* app);
|
||||
lash_proxy(
|
||||
Patchage* app,
|
||||
session * session_ptr);
|
||||
~lash_proxy();
|
||||
|
||||
void get_loaded_projects(std::list<std::string>& projects);
|
||||
|
@ -64,6 +68,7 @@ private:
|
|||
|
||||
Patchage* _app;
|
||||
bool _server_responding;
|
||||
session * _session_ptr;
|
||||
};
|
||||
|
||||
#endif // #ifndef LASH_PROXY_HPP__89E81B38_627F_41B9_AD08_DB119FB5F34C__INCLUDED
|
||||
|
|
|
@ -24,13 +24,14 @@
|
|||
#include "project_list.hpp"
|
||||
#include "Widget.hpp"
|
||||
#include "Patchage.hpp"
|
||||
#include "session.hpp"
|
||||
|
||||
struct project_list_column_record : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
Gtk::TreeModelColumn<Glib::ustring> name;
|
||||
};
|
||||
|
||||
struct project_list_impl
|
||||
struct project_list_impl : public sigc::trackable
|
||||
{
|
||||
Patchage *_app;
|
||||
Widget<Gtk::TreeView> _widget;
|
||||
|
@ -42,6 +43,9 @@ struct project_list_impl
|
|||
Glib::RefPtr<Gnome::Glade::Xml> xml,
|
||||
Patchage * app);
|
||||
|
||||
void project_added(const string& project_name);
|
||||
void project_closed(const string& project_name);
|
||||
|
||||
bool on_button_press_event(GdkEventButton * event);
|
||||
|
||||
void on_menu_popup_load_project();
|
||||
|
@ -53,9 +57,12 @@ struct project_list_impl
|
|||
|
||||
project_list::project_list(
|
||||
Glib::RefPtr<Gnome::Glade::Xml> xml,
|
||||
Patchage * app)
|
||||
Patchage * app,
|
||||
session * session_ptr)
|
||||
{
|
||||
_impl_ptr = new project_list_impl(xml, app);
|
||||
session_ptr->_signal_project_added.connect(mem_fun(_impl_ptr, &project_list_impl::project_added));
|
||||
session_ptr->_signal_project_closed.connect(mem_fun(_impl_ptr, &project_list_impl::project_closed));
|
||||
}
|
||||
|
||||
project_list::~project_list()
|
||||
|
@ -177,39 +184,39 @@ project_list_impl::on_menu_popup_close_all_projects()
|
|||
}
|
||||
|
||||
void
|
||||
project_list::set_lash_availability(
|
||||
bool lash_active)
|
||||
{
|
||||
_impl_ptr->_widget->set_sensitive(lash_active);
|
||||
}
|
||||
|
||||
void
|
||||
project_list::project_added(
|
||||
project_list_impl::project_added(
|
||||
const string& project_name)
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
|
||||
row = *(_impl_ptr->_model->append());
|
||||
row[_impl_ptr->_columns.name] = project_name;
|
||||
row = *(_model->append());
|
||||
row[_columns.name] = project_name;
|
||||
}
|
||||
|
||||
void
|
||||
project_list::project_closed(
|
||||
project_list_impl::project_closed(
|
||||
const string& project_name)
|
||||
{
|
||||
Gtk::TreeModel::Children children = _impl_ptr->_model->children();
|
||||
Gtk::TreeModel::Children children = _model->children();
|
||||
Gtk::TreeModel::Children::iterator iter = children.begin();
|
||||
|
||||
while(iter != children.end())
|
||||
{
|
||||
Gtk::TreeModel::Row row = *iter;
|
||||
|
||||
if (row[_impl_ptr->_columns.name] == project_name)
|
||||
if (row[_columns.name] == project_name)
|
||||
{
|
||||
_impl_ptr->_model->erase(iter);
|
||||
_model->erase(iter);
|
||||
return;
|
||||
}
|
||||
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
project_list::set_lash_availability(
|
||||
bool lash_active)
|
||||
{
|
||||
_impl_ptr->_widget->set_sensitive(lash_active);
|
||||
}
|
||||
|
|
|
@ -21,21 +21,20 @@
|
|||
|
||||
struct project_list_impl;
|
||||
class Patchage;
|
||||
class session;
|
||||
|
||||
class project_list
|
||||
{
|
||||
public:
|
||||
project_list(
|
||||
Glib::RefPtr<Gnome::Glade::Xml> xml,
|
||||
Patchage* app);
|
||||
Patchage* app,
|
||||
session * session_ptr);
|
||||
|
||||
~project_list();
|
||||
|
||||
void set_lash_availability(bool lash_active);
|
||||
|
||||
void project_added(const string& project_name);
|
||||
void project_closed(const string& project_name);
|
||||
|
||||
private:
|
||||
project_list_impl * _impl_ptr;
|
||||
};
|
||||
|
|
|
@ -17,12 +17,6 @@
|
|||
*/
|
||||
|
||||
#include "common.hpp"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
#include "project.hpp"
|
||||
#include "session.hpp"
|
||||
|
||||
|
@ -46,13 +40,16 @@ void
|
|||
session::project_add(
|
||||
const std::string& project_name)
|
||||
{
|
||||
shared_ptr<project> project_ptr(new project(project_name));
|
||||
//shared_ptr<project> project_ptr(new project(project_name));
|
||||
|
||||
_impl_ptr->projects.push_back(project_ptr);
|
||||
//_impl_ptr->projects.push_back(project_ptr);
|
||||
|
||||
_signal_project_added.emit(project_name);
|
||||
}
|
||||
|
||||
void
|
||||
session::project_close(
|
||||
const std::string& project_name)
|
||||
{
|
||||
_signal_project_closed.emit(project_name);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ public:
|
|||
project_close(
|
||||
const std::string& project_name);
|
||||
|
||||
sigc::signal<void, const std::string&> _signal_project_added;
|
||||
sigc::signal<void, const std::string&> _signal_project_closed;
|
||||
|
||||
private:
|
||||
session_impl * _impl_ptr;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue