Update project list on project added/closed notifications from lashd
This commit is contained in:
parent
96aff96c38
commit
770e79c86a
|
@ -29,3 +29,6 @@ patchage_LDADD += @DBUS_LIBS@
|
|||
|
||||
patchage_SOURCES += lash_proxy.cpp
|
||||
patchage_SOURCES += lash_proxy.hpp
|
||||
|
||||
patchage_SOURCES += project_list.cpp
|
||||
patchage_SOURCES += project_list.hpp
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include "PatchageCanvas.hpp"
|
||||
#include "StateManager.hpp"
|
||||
#include "lash_proxy.hpp"
|
||||
#include "project_list.hpp"
|
||||
|
||||
//#define LOG_TO_STD
|
||||
#define LOG_TO_STATUS
|
||||
|
@ -108,7 +110,6 @@ Patchage::Patchage(int argc, char** argv)
|
|||
, INIT_WIDGET(_toolbar)
|
||||
, INIT_WIDGET(_zoom_full_but)
|
||||
, INIT_WIDGET(_zoom_normal_but)
|
||||
, INIT_WIDGET(_projects_list)
|
||||
{
|
||||
_settings_filename = getenv("HOME");
|
||||
_settings_filename += "/.patchagerc";
|
||||
|
@ -210,8 +211,10 @@ Patchage::Patchage(int argc, char** argv)
|
|||
|
||||
_about_win->set_transient_for(*_main_win);
|
||||
|
||||
_project_list = new project_list(xml);
|
||||
|
||||
_lash = new lash_proxy(this);
|
||||
|
||||
|
||||
_jack_driver = new JackDriver(this);
|
||||
|
||||
_menu_jack_start->signal_activate().connect(
|
||||
|
@ -235,6 +238,7 @@ Patchage::~Patchage()
|
|||
{
|
||||
delete _jack_driver;
|
||||
delete _lash;
|
||||
delete _project_list;
|
||||
delete _state_manager;
|
||||
|
||||
_about_win.destroy();
|
||||
|
@ -675,3 +679,17 @@ Patchage::dbus_call(
|
|||
|
||||
return ap;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
|
@ -33,6 +34,7 @@ class PatchageCanvas;
|
|||
class JackDriver;
|
||||
class lash_proxy;
|
||||
class StateManager;
|
||||
class project_list;
|
||||
|
||||
class Patchage {
|
||||
public:
|
||||
|
@ -80,6 +82,14 @@ public:
|
|||
int in_type,
|
||||
...);
|
||||
|
||||
void
|
||||
on_project_added(
|
||||
const std::string& project_name);
|
||||
|
||||
void
|
||||
on_project_closed(
|
||||
const std::string& project_name);
|
||||
|
||||
DBusError _dbus_error;
|
||||
DBusConnection* _dbus_connection;
|
||||
|
||||
|
@ -123,6 +133,7 @@ protected:
|
|||
|
||||
JackDriver* _jack_driver;
|
||||
lash_proxy * _lash;
|
||||
project_list * _project_list;
|
||||
StateManager* _state_manager;
|
||||
|
||||
Gtk::Main* _gtk_main;
|
||||
|
@ -153,7 +164,6 @@ protected:
|
|||
Widget<Gtk::Toolbar> _toolbar;
|
||||
Widget<Gtk::ToolButton> _zoom_full_but;
|
||||
Widget<Gtk::ToolButton> _zoom_normal_but;
|
||||
Widget<Gtk::TreeView> _projects_list;
|
||||
};
|
||||
|
||||
#endif // PATCHAGE_PATCHAGE_HPP
|
||||
|
|
|
@ -25,6 +25,16 @@ template <typename W>
|
|||
class Widget : public boost::noncopyable {
|
||||
public:
|
||||
Widget(Glib::RefPtr<Gnome::Glade::Xml> xml, const std::string& name) {
|
||||
init(xml, name);
|
||||
}
|
||||
|
||||
Widget()
|
||||
{
|
||||
_me = 0;
|
||||
}
|
||||
|
||||
void init(Glib::RefPtr<Gnome::Glade::Xml> xml, const std::string& name)
|
||||
{
|
||||
xml->get_widget(name.c_str(), _me);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// -*- Mode: C++ ; indent-tabs-mode: t -*-
|
||||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef COMMON_HPP__AA9070A8_1E8C_4C6E_9769_395BF3D848C0__INCLUDED
|
||||
#define COMMON_HPP__AA9070A8_1E8C_4C6E_9769_395BF3D848C0__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#endif // #ifndef COMMON_HPP__AA9070A8_1E8C_4C6E_9769_395BF3D848C0__INCLUDED
|
|
@ -116,7 +116,7 @@ lash_proxy::dbus_message_hook(
|
|||
}
|
||||
|
||||
me->info_msg((string)"Project '" + project_name + "' added.");
|
||||
// do something here
|
||||
me->_app->on_project_added(project_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ lash_proxy::dbus_message_hook(
|
|||
}
|
||||
|
||||
me->info_msg((string)"Project '" + project_name + "' closed.");
|
||||
// do something here
|
||||
me->_app->on_project_closed(project_name);
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
// -*- Mode: C++ ; indent-tabs-mode: t -*-
|
||||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <libglademm/xml.h>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "project_list.hpp"
|
||||
#include "Widget.hpp"
|
||||
|
||||
struct project_list_column_record : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
Gtk::TreeModelColumn<Glib::ustring> name;
|
||||
};
|
||||
|
||||
struct project_list_impl
|
||||
{
|
||||
Widget<Gtk::TreeView> widget;
|
||||
project_list_column_record columns;
|
||||
Glib::RefPtr<Gtk::ListStore> model;
|
||||
};
|
||||
|
||||
project_list::project_list(
|
||||
Glib::RefPtr<Gnome::Glade::Xml> xml)
|
||||
{
|
||||
_impl_ptr = new project_list_impl;
|
||||
|
||||
_impl_ptr->widget.init(xml, "projects_list");
|
||||
|
||||
_impl_ptr->columns.add(_impl_ptr->columns.name);
|
||||
|
||||
_impl_ptr->model = Gtk::ListStore::create(_impl_ptr->columns);
|
||||
_impl_ptr->widget->set_model(_impl_ptr->model);
|
||||
|
||||
_impl_ptr->widget->append_column("Project Name", _impl_ptr->columns.name);
|
||||
}
|
||||
|
||||
project_list::~project_list()
|
||||
{
|
||||
delete _impl_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
project_list::project_added(
|
||||
const string& project_name)
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
|
||||
row = *(_impl_ptr->model->append());
|
||||
row[_impl_ptr->columns.name] = project_name;
|
||||
}
|
||||
|
||||
void
|
||||
project_list::project_closed(
|
||||
const string& project_name)
|
||||
{
|
||||
Gtk::TreeModel::Children children = _impl_ptr->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)
|
||||
{
|
||||
_impl_ptr->model->erase(iter);
|
||||
return;
|
||||
}
|
||||
|
||||
iter++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// -*- Mode: C++ ; indent-tabs-mode: t -*-
|
||||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef PROJECT_LIST_HPP__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
|
||||
#define PROJECT_LIST_HPP__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
|
||||
|
||||
struct project_list_impl;
|
||||
|
||||
class project_list
|
||||
{
|
||||
public:
|
||||
project_list(Glib::RefPtr<Gnome::Glade::Xml> xml);
|
||||
~project_list();
|
||||
|
||||
void project_added(const string& project_name);
|
||||
void project_closed(const string& project_name);
|
||||
|
||||
private:
|
||||
project_list_impl * _impl_ptr;
|
||||
};
|
||||
|
||||
#endif // #ifndef PROJECT_LIST_HPP__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
|
Loading…
Reference in New Issue