2006-08-11 02:45:41 +02:00
|
|
|
// src/schedulables_tree_widget.cc - Copyright 2005, 2006, University
|
|
|
|
// of Padova, dept. of Pure and Applied
|
|
|
|
// Mathematics
|
|
|
|
//
|
|
|
|
// This file is part of SGPEMv2.
|
|
|
|
//
|
|
|
|
// This 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.
|
|
|
|
//
|
|
|
|
// SGPEMv2 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with SGPEMv2; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
#include "schedulables_tree_widget.hh"
|
2006-08-12 02:35:40 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <gtk/gtk.h>
|
2006-08-11 02:45:41 +02:00
|
|
|
|
|
|
|
using namespace sgpem;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
2006-08-12 02:35:40 +02:00
|
|
|
using Gnome::Glade::Xml;
|
2006-08-11 02:45:41 +02:00
|
|
|
|
2006-08-12 02:35:40 +02:00
|
|
|
SchedulablesTreeWidget::SchedulablesTreeWidget() :
|
|
|
|
_add_process_dialog_glade(Xml::create(GLADEDIR "/add-process-dialog.glade"))
|
2006-08-11 02:45:41 +02:00
|
|
|
{
|
|
|
|
_columns.add(_column);
|
|
|
|
_model = TreeStore::create(_columns);
|
|
|
|
|
|
|
|
set_model(_model);
|
2006-08-12 02:35:40 +02:00
|
|
|
|
|
|
|
/** JUST A BIT OF DATA FOR TESTING **/
|
2006-08-11 02:45:41 +02:00
|
|
|
|
|
|
|
Gtk::TreeModel::Row row1 = *(_model->append());
|
|
|
|
row1[_column] = ustring("ciccio");
|
|
|
|
|
|
|
|
Gtk::TreeModel::Row row2 = *(_model->append());
|
|
|
|
row2[_column] = ustring("pippo");
|
|
|
|
|
|
|
|
append_column("schedulables", _column);
|
2006-08-12 02:35:40 +02:00
|
|
|
|
|
|
|
/** POPUP MENU **/
|
|
|
|
|
|
|
|
_action_group = Gtk::ActionGroup::create();
|
|
|
|
|
|
|
|
// _action_group->add( Gtk::Action::create("ContextMenu", "Schedulables") );
|
|
|
|
// _action_group->add( Gtk::Action::create("Add Process", Gtk::Stock::NEW),
|
|
|
|
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_new) );
|
|
|
|
_action_group->add( Gtk::Action::create("AddProcess", "Add Process"),
|
|
|
|
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) );
|
|
|
|
//_action_group->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
|
|
|
|
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_quit) );
|
|
|
|
|
|
|
|
_UIManager = Gtk::UIManager::create();
|
|
|
|
_UIManager->insert_action_group(_action_group);
|
|
|
|
|
|
|
|
Glib::ustring ui_info =
|
|
|
|
"<ui>"
|
|
|
|
" <popup name='PopupMenu'>"
|
|
|
|
// " <menuitem action='ContextMenu'/>"
|
|
|
|
" <menuitem action='AddProcess'/>"
|
|
|
|
" </popup>"
|
|
|
|
"</ui>";
|
|
|
|
|
|
|
|
_UIManager->add_ui_from_string(ui_info);
|
|
|
|
_menu = dynamic_cast<Gtk::Menu*>(_UIManager->get_widget("/PopupMenu"));
|
|
|
|
|
|
|
|
/** DIALOGS **/
|
|
|
|
_add_process_dialog_glade->get_widget("AddProcessDialog", _add_process_dialog);
|
|
|
|
//FIXME why do I need to call this? Is it reasonable?
|
|
|
|
_add_process_dialog->hide();
|
|
|
|
|
2006-08-11 02:45:41 +02:00
|
|
|
set_headers_visible(false);
|
|
|
|
}
|
|
|
|
|
2006-08-12 02:35:40 +02:00
|
|
|
bool SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
|
|
|
|
{
|
|
|
|
TreeView::on_button_press_event(event);
|
|
|
|
|
|
|
|
if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
|
|
|
|
{
|
|
|
|
_menu->popup(event->button, event->time);
|
|
|
|
return true; //It has been handled.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-11 02:45:41 +02:00
|
|
|
|
|
|
|
SchedulablesTreeWidget::~SchedulablesTreeWidget()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void
|
|
|
|
SchedulablesTreeWidget::update(const History& history)
|
|
|
|
{
|
|
|
|
}
|
2006-08-12 02:35:40 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
SchedulablesTreeWidget::_on_add_process()
|
|
|
|
{
|
|
|
|
switch(_add_process_dialog->run())
|
|
|
|
{
|
|
|
|
case RESPONSE_OK:
|
|
|
|
std::cout << "added the process ;-)\n";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::cout << "operation cancelled ;-)\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
_add_process_dialog->hide();
|
|
|
|
}
|