2009-07-30 01:16:07 +03:00
|
|
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
|
|
|
/*
|
|
|
|
* LADI Session Handler (ladish)
|
|
|
|
*
|
2009-08-22 03:46:20 +03:00
|
|
|
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
2008-06-15 11:50:12 +03:00
|
|
|
*
|
2009-07-30 01:16:07 +03:00
|
|
|
**************************************************************************
|
|
|
|
* This file contains implementation of the project_list class
|
|
|
|
**************************************************************************
|
|
|
|
*
|
|
|
|
* LADI Session Handler 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.
|
2008-06-15 11:50:12 +03:00
|
|
|
*
|
2009-07-30 01:16:07 +03:00
|
|
|
* LADI Session Handler 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 more details.
|
2008-06-15 11:50:12 +03:00
|
|
|
*
|
2009-07-30 01:16:07 +03:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
* or write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-06-15 11:50:12 +03:00
|
|
|
*/
|
|
|
|
|
2009-07-30 01:27:42 +03:00
|
|
|
#include "common.h"
|
2009-08-22 03:46:20 +03:00
|
|
|
#include "world_tree.h"
|
2009-08-22 04:42:54 +03:00
|
|
|
#include "glade.h"
|
2009-07-30 01:27:42 +03:00
|
|
|
|
2009-08-22 03:46:20 +03:00
|
|
|
#if 0
|
2008-06-15 22:36:57 +03:00
|
|
|
#include <iostream>
|
2008-06-15 11:50:12 +03:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <libglademm/xml.h>
|
|
|
|
|
|
|
|
#include "project_list.hpp"
|
|
|
|
#include "Widget.hpp"
|
2008-06-15 23:55:45 +03:00
|
|
|
#include "Patchage.hpp"
|
2008-07-03 22:55:43 +03:00
|
|
|
#include "session.hpp"
|
2008-07-03 23:27:11 +03:00
|
|
|
#include "project.hpp"
|
2008-07-04 22:47:59 +03:00
|
|
|
#include "project_properties.hpp"
|
2008-07-05 22:33:13 +03:00
|
|
|
#include "lash_client.hpp"
|
2008-07-04 22:47:59 +03:00
|
|
|
#include "globals.hpp"
|
2008-06-15 11:50:12 +03:00
|
|
|
|
|
|
|
struct project_list_column_record : public Gtk::TreeModel::ColumnRecord
|
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModelColumn<Glib::ustring> name;
|
2009-07-30 01:53:36 +03:00
|
|
|
Gtk::TreeModelColumn<boost::shared_ptr<project> > project_ptr;
|
|
|
|
Gtk::TreeModelColumn<boost::shared_ptr<lash_client> > client_ptr;
|
2008-06-15 11:50:12 +03:00
|
|
|
};
|
|
|
|
|
2008-07-03 22:55:43 +03:00
|
|
|
struct project_list_impl : public sigc::trackable
|
2008-06-15 11:50:12 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
Patchage *_app;
|
|
|
|
Widget<Gtk::TreeView> _widget;
|
|
|
|
project_list_column_record _columns;
|
|
|
|
Glib::RefPtr<Gtk::TreeStore> _model;
|
|
|
|
Gtk::Menu _menu_popup;
|
|
|
|
|
|
|
|
project_list_impl(
|
|
|
|
Glib::RefPtr<Gnome::Glade::Xml> xml,
|
|
|
|
Patchage * app);
|
|
|
|
|
2009-07-30 01:53:36 +03:00
|
|
|
void project_added(boost::shared_ptr<project> project_ptr);
|
|
|
|
void project_closed(boost::shared_ptr<project> project_ptr);
|
2009-07-20 04:59:25 +03:00
|
|
|
void project_renamed(Gtk::TreeModel::iterator iter);
|
2009-07-30 01:53:36 +03:00
|
|
|
void client_added(boost::shared_ptr<lash_client> client_ptr, Gtk::TreeModel::iterator iter);
|
|
|
|
void client_removed(boost::shared_ptr<lash_client> client_ptr, Gtk::TreeModel::iterator iter);
|
2009-07-20 04:59:25 +03:00
|
|
|
void client_renamed(Gtk::TreeModel::iterator iter);
|
|
|
|
|
|
|
|
bool on_button_press_event(GdkEventButton * event);
|
|
|
|
|
|
|
|
void on_menu_popup_load_project();
|
|
|
|
void on_menu_popup_save_all_projects();
|
2009-07-30 01:53:36 +03:00
|
|
|
void on_menu_popup_save_project(boost::shared_ptr<project> project_ptr);
|
|
|
|
void on_menu_popup_close_project(boost::shared_ptr<project> project_ptr);
|
|
|
|
void on_menu_popup_project_properties(boost::shared_ptr<project> project_ptr);
|
2009-07-20 04:59:25 +03:00
|
|
|
void on_menu_popup_close_all_projects();
|
2008-06-15 11:50:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
project_list::project_list(
|
2009-07-20 04:59:25 +03:00
|
|
|
Patchage * app,
|
|
|
|
session * session_ptr)
|
2008-06-15 11:50:12 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_impl_ptr = new project_list_impl(g_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));
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
project_list::~project_list()
|
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
delete _impl_ptr;
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
2008-06-15 23:55:45 +03:00
|
|
|
project_list_impl::project_list_impl(
|
2009-07-20 04:59:25 +03:00
|
|
|
Glib::RefPtr<Gnome::Glade::Xml> xml,
|
|
|
|
Patchage * app)
|
|
|
|
: _app(app)
|
2008-06-15 22:36:57 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_widget.init(xml, "projects_list");
|
2008-06-15 22:36:57 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_columns.add(_columns.name);
|
|
|
|
_columns.add(_columns.project_ptr);
|
|
|
|
_columns.add(_columns.client_ptr);
|
2008-06-15 11:50:12 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_model = Gtk::TreeStore::create(_columns);
|
|
|
|
_widget->set_model(_model);
|
2008-06-15 11:50:12 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_widget->append_column("LASH projects", _columns.name);
|
2008-06-15 11:50:12 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_menu_popup.accelerate(*_widget);
|
2008-06-15 11:50:12 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_widget->signal_button_press_event().connect(sigc::mem_fun(*this, &project_list_impl::on_button_press_event), false);
|
2008-06-15 11:50:12 +03:00
|
|
|
}
|
|
|
|
|
2008-06-15 22:36:57 +03:00
|
|
|
bool
|
|
|
|
project_list_impl::on_button_press_event(GdkEventButton * event_ptr)
|
2008-06-15 11:50:12 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
// Then do our custom stuff:
|
|
|
|
if (event_ptr->type == GDK_BUTTON_PRESS && event_ptr->button == 3)
|
|
|
|
{
|
|
|
|
Glib::RefPtr<Gtk::TreeView::Selection> selection = _widget->get_selection();
|
|
|
|
|
|
|
|
Gtk::TreeModel::Path path;
|
|
|
|
Gtk::TreeViewColumn * column_ptr;
|
|
|
|
int cell_x;
|
|
|
|
int cell_y;
|
|
|
|
|
|
|
|
Gtk::Menu::MenuList& menulist = _menu_popup.items();
|
|
|
|
|
|
|
|
menulist.clear();
|
|
|
|
|
|
|
|
menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Load project...", sigc::mem_fun(*this, &project_list_impl::on_menu_popup_load_project)));
|
|
|
|
|
|
|
|
menulist.push_back(Gtk::Menu_Helpers::MenuElem("Save _all projects", sigc::mem_fun(*this, &project_list_impl::on_menu_popup_save_all_projects)));
|
|
|
|
|
|
|
|
if (_widget->get_path_at_pos((int)event_ptr->x, (int)event_ptr->y, path, column_ptr, cell_x, cell_y))
|
|
|
|
{
|
|
|
|
//cout << path.to_string() << endl;
|
|
|
|
selection->unselect_all();
|
|
|
|
selection->select(path);
|
|
|
|
|
|
|
|
Gtk::TreeIter iter = selection->get_selected();
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr = (*iter)[_columns.project_ptr];
|
|
|
|
std::string name;
|
2009-07-20 04:59:25 +03:00
|
|
|
|
|
|
|
if (project_ptr)
|
|
|
|
{
|
|
|
|
project_ptr->get_name(name);
|
|
|
|
|
|
|
|
menulist.push_back(
|
|
|
|
Gtk::Menu_Helpers::MenuElem(
|
2009-07-30 01:53:36 +03:00
|
|
|
(std::string)"_Save project '" + name + "'",
|
2009-07-20 04:59:25 +03:00
|
|
|
sigc::bind(
|
|
|
|
sigc::mem_fun(
|
|
|
|
*this,
|
|
|
|
&project_list_impl::on_menu_popup_save_project),
|
|
|
|
project_ptr)));
|
|
|
|
menulist.push_back(
|
|
|
|
Gtk::Menu_Helpers::MenuElem(
|
2009-07-30 01:53:36 +03:00
|
|
|
(std::string)"_Close project '" + name + "'",
|
2009-07-20 04:59:25 +03:00
|
|
|
sigc::bind(
|
|
|
|
sigc::mem_fun(
|
|
|
|
*this,
|
|
|
|
&project_list_impl::on_menu_popup_close_project),
|
|
|
|
project_ptr)));
|
|
|
|
|
|
|
|
menulist.push_back(
|
|
|
|
Gtk::Menu_Helpers::MenuElem(
|
2009-07-30 01:53:36 +03:00
|
|
|
(std::string)"_Project '" + name + "' properties",
|
2009-07-20 04:59:25 +03:00
|
|
|
sigc::bind(
|
|
|
|
sigc::mem_fun(
|
|
|
|
*this,
|
|
|
|
&project_list_impl::on_menu_popup_project_properties),
|
|
|
|
project_ptr)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//cout << "No row" << endl;
|
|
|
|
selection->unselect_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
menulist.push_back(Gtk::Menu_Helpers::MenuElem("Cl_ose all projects", sigc::mem_fun(*this, &project_list_impl::on_menu_popup_close_all_projects)));
|
|
|
|
|
|
|
|
_menu_popup.popup(event_ptr->button, event_ptr->time);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_load_project()
|
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_app->load_project_ask();
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_save_all_projects()
|
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_app->save_all_projects();
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_save_project(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr)
|
2008-06-15 22:36:57 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
std::string name;
|
2008-07-05 03:32:57 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
project_ptr->get_name(name);
|
|
|
|
_app->save_project(name);
|
2008-06-15 22:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_close_project(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr)
|
2008-06-15 22:36:57 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
std::string name;
|
2008-07-05 03:32:57 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
project_ptr->get_name(name);
|
|
|
|
_app->close_project(name);
|
2008-06-15 23:55:45 +03:00
|
|
|
}
|
|
|
|
|
2008-07-04 22:47:59 +03:00
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_project_properties(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr)
|
2008-07-04 22:47:59 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
project_properties_dialog dialog;
|
2008-07-04 22:47:59 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
dialog.run(project_ptr);
|
2008-07-04 22:47:59 +03:00
|
|
|
}
|
|
|
|
|
2008-06-15 23:55:45 +03:00
|
|
|
void
|
|
|
|
project_list_impl::on_menu_popup_close_all_projects()
|
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_app->close_all_projects();
|
2008-06-15 11:50:12 +03:00
|
|
|
}
|
|
|
|
|
2008-06-15 16:24:12 +03:00
|
|
|
void
|
2008-07-03 22:55:43 +03:00
|
|
|
project_list_impl::project_added(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr)
|
2008-06-15 11:50:12 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
Gtk::TreeModel::iterator child_iter;
|
|
|
|
Gtk::TreeModel::Row row;
|
2009-07-30 01:53:36 +03:00
|
|
|
std::string project_name;
|
2009-07-20 04:59:25 +03:00
|
|
|
|
|
|
|
project_ptr->get_name(project_name);
|
|
|
|
|
|
|
|
if (project_ptr->get_modified_status())
|
|
|
|
{
|
|
|
|
project_name += " *";
|
|
|
|
}
|
|
|
|
|
|
|
|
iter = _model->append();
|
|
|
|
row = *iter;
|
|
|
|
row[_columns.name] = project_name;
|
|
|
|
row[_columns.project_ptr] = project_ptr;
|
|
|
|
|
|
|
|
project_ptr->_signal_renamed.connect(bind(mem_fun(this, &project_list_impl::project_renamed), iter));
|
|
|
|
project_ptr->_signal_modified_status_changed.connect(bind(mem_fun(this, &project_list_impl::project_renamed), iter));
|
|
|
|
project_ptr->_signal_client_added.connect(bind(mem_fun(this, &project_list_impl::client_added), iter));
|
|
|
|
project_ptr->_signal_client_removed.connect(bind(mem_fun(this, &project_list_impl::client_removed), iter));
|
2008-06-15 11:50:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-07-03 22:55:43 +03:00
|
|
|
project_list_impl::project_closed(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr)
|
2008-06-15 11:50:12 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> temp_project_ptr;
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::Children children = _model->children();
|
|
|
|
Gtk::TreeModel::Children::iterator iter = children.begin();
|
2008-07-03 23:50:32 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
while(iter != children.end())
|
|
|
|
{
|
|
|
|
Gtk::TreeModel::Row row = *iter;
|
2008-07-03 23:50:32 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
temp_project_ptr = row[_columns.project_ptr];
|
2008-07-03 23:50:32 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
if (temp_project_ptr == project_ptr)
|
|
|
|
{
|
|
|
|
_model->erase(iter);
|
|
|
|
return;
|
|
|
|
}
|
2008-07-03 23:50:32 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
iter++;
|
|
|
|
}
|
2008-07-03 23:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
project_list_impl::project_renamed(
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::iterator iter)
|
2008-07-03 23:50:32 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<project> project_ptr;
|
|
|
|
std::string project_name;
|
2008-06-15 11:50:12 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::Row row = *iter;
|
2008-07-03 23:27:11 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
project_ptr = row[_columns.project_ptr];
|
|
|
|
project_ptr->get_name(project_name);
|
2008-07-04 02:28:39 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
if (project_ptr->get_modified_status())
|
|
|
|
{
|
|
|
|
project_name += " *";
|
|
|
|
}
|
2008-07-04 02:28:39 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
row[_columns.name] = project_name;
|
2008-06-15 11:50:12 +03:00
|
|
|
}
|
2008-07-03 22:55:43 +03:00
|
|
|
|
2008-07-05 22:33:13 +03:00
|
|
|
void
|
|
|
|
project_list_impl::client_added(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<lash_client> client_ptr,
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::iterator iter)
|
2008-07-05 22:33:13 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
std::string name;
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::Path path = _model->get_path(iter);
|
|
|
|
Gtk::TreeModel::Row row = *iter;
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
client_ptr->get_name(name);
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
iter = _model->append(row.children());
|
|
|
|
row = *iter;
|
|
|
|
row[_columns.name] = name;
|
|
|
|
row[_columns.client_ptr] = client_ptr;
|
2008-09-20 23:31:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
client_ptr->_signal_renamed.connect(bind(mem_fun(this, &project_list_impl::client_renamed), iter));
|
2008-07-05 23:08:50 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
_widget->expand_row(path, false);
|
2008-07-05 22:33:13 +03:00
|
|
|
}
|
|
|
|
|
2008-09-20 23:31:13 +03:00
|
|
|
void
|
|
|
|
project_list_impl::client_renamed(
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::iterator iter)
|
2008-09-20 23:31:13 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<lash_client> client_ptr;
|
|
|
|
std::string client_name;
|
2008-09-20 23:31:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::Row row = *iter;
|
2008-09-20 23:31:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
client_ptr = row[_columns.client_ptr];
|
|
|
|
client_ptr->get_name(client_name);
|
2008-09-20 23:31:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
row[_columns.name] = client_name;
|
2008-09-20 23:31:13 +03:00
|
|
|
}
|
|
|
|
|
2008-07-05 22:33:13 +03:00
|
|
|
void
|
|
|
|
project_list_impl::client_removed(
|
2009-07-30 01:53:36 +03:00
|
|
|
boost::shared_ptr<lash_client> client_ptr,
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::iterator iter)
|
2008-07-05 22:33:13 +03:00
|
|
|
{
|
2009-07-30 01:53:36 +03:00
|
|
|
std::string name;
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeModel::Path path = _model->get_path(iter);
|
|
|
|
Gtk::TreeModel::Row row = *iter;
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
client_ptr->get_name(name);
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
Gtk::TreeNodeChildren childs = row.children();
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
for (Gtk::TreeModel::iterator child_iter = childs.begin(); iter != childs.end(); child_iter++)
|
|
|
|
{
|
|
|
|
row = *child_iter;
|
2008-07-05 22:33:13 +03:00
|
|
|
|
2009-07-20 04:59:25 +03:00
|
|
|
if (row[_columns.name] == name)
|
|
|
|
{
|
|
|
|
_widget->expand_row(path, false);
|
|
|
|
_model->erase(child_iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-07-05 22:33:13 +03:00
|
|
|
}
|
|
|
|
|
2008-07-03 22:55:43 +03:00
|
|
|
void
|
|
|
|
project_list::set_lash_availability(
|
2009-07-20 04:59:25 +03:00
|
|
|
bool lash_active)
|
2008-07-03 22:55:43 +03:00
|
|
|
{
|
2009-07-20 04:59:25 +03:00
|
|
|
_impl_ptr->_widget->set_sensitive(lash_active);
|
2008-07-03 22:55:43 +03:00
|
|
|
}
|
2009-08-22 03:46:20 +03:00
|
|
|
#endif
|
|
|
|
|
2009-08-22 04:42:54 +03:00
|
|
|
enum
|
|
|
|
{
|
2009-08-22 15:18:03 +03:00
|
|
|
COL_VIEW = 0,
|
|
|
|
COL_NAME,
|
2009-08-22 04:42:54 +03:00
|
|
|
NUM_COLS
|
|
|
|
};
|
|
|
|
|
|
|
|
GtkWidget * g_world_tree_widget;
|
|
|
|
GtkTreeStore * g_treestore;
|
|
|
|
|
2009-08-22 15:59:54 +03:00
|
|
|
static
|
|
|
|
gboolean
|
|
|
|
on_select(
|
|
|
|
GtkTreeSelection * selection,
|
|
|
|
GtkTreeModel * model,
|
|
|
|
GtkTreePath * path,
|
|
|
|
gboolean path_currently_selected,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
graph_view_handle view;
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter(model, &iter, path))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get(model, &iter, COL_VIEW, &view, -1);
|
|
|
|
//lash_info("%s is going to be %s.", get_view_name(view), path_currently_selected ? "unselected" : "selected");
|
|
|
|
if (!path_currently_selected)
|
|
|
|
{
|
|
|
|
activate_view(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-08-22 03:46:20 +03:00
|
|
|
void world_tree_init(void)
|
|
|
|
{
|
2009-08-22 04:42:54 +03:00
|
|
|
GtkTreeViewColumn * col;
|
|
|
|
GtkCellRenderer * renderer;
|
2009-08-22 15:59:54 +03:00
|
|
|
GtkTreeSelection * selection;
|
2009-08-22 04:42:54 +03:00
|
|
|
|
|
|
|
g_world_tree_widget = get_glade_widget("world_tree");
|
|
|
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(g_world_tree_widget), FALSE);
|
|
|
|
|
|
|
|
col = gtk_tree_view_column_new();
|
|
|
|
gtk_tree_view_column_set_title(col, "Name");
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(g_world_tree_widget), col);
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_add_attribute(col, renderer, "text", COL_NAME);
|
|
|
|
|
2009-08-22 15:18:03 +03:00
|
|
|
g_treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_POINTER, G_TYPE_STRING);
|
2009-08-22 04:42:54 +03:00
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(g_world_tree_widget), GTK_TREE_MODEL(g_treestore));
|
2009-08-22 15:59:54 +03:00
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_world_tree_widget));
|
|
|
|
gtk_tree_selection_set_select_function(selection, on_select, NULL, NULL);
|
2009-08-22 03:46:20 +03:00
|
|
|
}
|
|
|
|
|
2009-08-22 15:59:54 +03:00
|
|
|
void world_tree_add(graph_view_handle view, bool force_activate)
|
2009-08-22 03:46:20 +03:00
|
|
|
{
|
2009-08-22 04:42:54 +03:00
|
|
|
GtkTreeIter iter;
|
2009-08-22 03:46:20 +03:00
|
|
|
|
2009-08-22 04:42:54 +03:00
|
|
|
gtk_tree_store_append(g_treestore, &iter, NULL);
|
2009-08-22 15:18:03 +03:00
|
|
|
gtk_tree_store_set(g_treestore, &iter, COL_VIEW, view, COL_NAME, get_view_name(view), -1);
|
2009-08-22 15:59:54 +03:00
|
|
|
|
|
|
|
/* select the first top level item */
|
|
|
|
if (force_activate || gtk_tree_model_iter_n_children(GTK_TREE_MODEL(g_treestore), NULL) == 1)
|
|
|
|
{
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_world_tree_widget)), &iter);
|
|
|
|
}
|
2009-08-22 03:46:20 +03:00
|
|
|
}
|
|
|
|
|
2009-08-22 15:18:03 +03:00
|
|
|
void world_tree_remove(graph_view_handle view)
|
2009-08-22 03:46:20 +03:00
|
|
|
{
|
2009-08-22 04:42:54 +03:00
|
|
|
GtkTreeIter iter;
|
2009-08-22 15:18:03 +03:00
|
|
|
graph_view_handle view2;
|
2009-08-22 04:42:54 +03:00
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(g_treestore), &iter))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2009-08-22 15:18:03 +03:00
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(g_treestore), &iter, COL_VIEW, &view2, -1);
|
|
|
|
if (view == view2)
|
2009-08-22 04:42:54 +03:00
|
|
|
{
|
|
|
|
gtk_tree_store_remove(g_treestore, &iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (gtk_tree_model_iter_next(GTK_TREE_MODEL(g_treestore), &iter));
|
|
|
|
}
|
2009-08-22 03:46:20 +03:00
|
|
|
}
|