use project object in signal instead of project name

This commit is contained in:
Nedko Arnaudov 2008-07-03 23:27:11 +03:00
parent c1d00c4ad7
commit 3c2dac1491
8 changed files with 77 additions and 24 deletions

View File

@ -28,6 +28,7 @@
#include <boost/format.hpp>
#include CONFIG_H_PATH
#include "common.hpp"
#include "GladeFile.hpp"
#include "jack_proxy.hpp"
#include "JackSettingsDialog.hpp"

View File

@ -24,6 +24,7 @@
#include <list>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/format.hpp>
using namespace boost;
using namespace std;

View File

@ -16,8 +16,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <boost/format.hpp>
#include "common.hpp"
#include "lash_proxy.hpp"
#include "session.hpp"

View File

@ -22,12 +22,19 @@
struct project_impl
{
string name;
time_t modification_time;
string comment;
};
project::project(const string& project_name)
project::project(
const string& name,
time_t modification_time,
const string& comment)
{
_impl_ptr = new project_impl;
_impl_ptr->name = project_name;
_impl_ptr->name = name;
_impl_ptr->modification_time = modification_time;
_impl_ptr->comment = comment;
}
project::~project()
@ -36,8 +43,20 @@ project::~project()
}
void
project::get_project_name(
string& project_name)
project::get_name(
string& name)
{
name = _impl_ptr->name;
}
void
project::get_modification_time(
time_t& modification_time)
{
}
void
get_comment(
string& comment)
{
project_name = _impl_ptr->name;
}

View File

@ -24,12 +24,24 @@ struct project_impl;
class project
{
public:
project(const std::string& project_name);
project(
const string& name,
time_t modification_time,
const string& comment);
~project();
void
get_project_name(
std::string& project_name);
get_name(
string& name);
void
get_modification_time(
time_t& modification_time);
void
get_comment(
string& comment);
private:
project_impl * _impl_ptr;

View File

@ -25,6 +25,7 @@
#include "Widget.hpp"
#include "Patchage.hpp"
#include "session.hpp"
#include "project.hpp"
struct project_list_column_record : public Gtk::TreeModel::ColumnRecord
{
@ -43,8 +44,8 @@ struct project_list_impl : public sigc::trackable
Glib::RefPtr<Gnome::Glade::Xml> xml,
Patchage * app);
void project_added(const string& project_name);
void project_closed(const string& project_name);
void project_added(shared_ptr<project> project_ptr);
void project_closed(shared_ptr<project> project_ptr);
bool on_button_press_event(GdkEventButton * event);
@ -185,9 +186,12 @@ project_list_impl::on_menu_popup_close_all_projects()
void
project_list_impl::project_added(
const string& project_name)
shared_ptr<project> project_ptr)
{
Gtk::TreeModel::Row row;
string project_name;
project_ptr->get_name(project_name);
row = *(_model->append());
row[_columns.name] = project_name;
@ -195,11 +199,14 @@ project_list_impl::project_added(
void
project_list_impl::project_closed(
const string& project_name)
shared_ptr<project> project_ptr)
{
string project_name;
Gtk::TreeModel::Children children = _model->children();
Gtk::TreeModel::Children::iterator iter = children.begin();
project_ptr->get_name(project_name);
while(iter != children.end())
{
Gtk::TreeModel::Row row = *iter;

View File

@ -19,6 +19,7 @@
#include "common.hpp"
#include "project.hpp"
#include "session.hpp"
#include <iostream>
struct session_impl
{
@ -38,18 +39,30 @@ session::~session()
void
session::project_add(
const std::string& project_name)
const string& project_name)
{
//shared_ptr<project> project_ptr(new project(project_name));
shared_ptr<project> project_ptr(new project(project_name, 0, ""));
//_impl_ptr->projects.push_back(project_ptr);
_impl_ptr->projects.push_back(project_ptr);
_signal_project_added.emit(project_name);
_signal_project_added.emit(project_ptr);
}
void
session::project_close(
const std::string& project_name)
const string& project_name)
{
_signal_project_closed.emit(project_name);
shared_ptr<project> project_ptr;
string temp_name;
for (list<shared_ptr<project> >::iterator iter = _impl_ptr->projects.begin(); iter != _impl_ptr->projects.end(); iter++)
{
project_ptr = *iter;
project_ptr->get_name(temp_name);
if (temp_name == project_name)
{
_signal_project_closed.emit(project_ptr);
}
}
}

View File

@ -20,6 +20,7 @@
#define SESSION_HPP__C870E949_EF2A_43E8_8FE8_55AE5A714172__INCLUDED
struct session_impl;
class project;
class session
{
@ -29,14 +30,14 @@ public:
void
project_add(
const std::string& project_name);
const string& project_name);
void
project_close(
const std::string& project_name);
const string& project_name);
sigc::signal<void, const std::string&> _signal_project_added;
sigc::signal<void, const std::string&> _signal_project_closed;
sigc::signal<void, shared_ptr<project> > _signal_project_added;
sigc::signal<void, shared_ptr<project> > _signal_project_closed;
private:
session_impl * _impl_ptr;