// 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" #include #include using namespace sgpem; using namespace Gtk; using namespace Glib; using Gnome::Glade::Xml; SchedulablesTreeWidget::SchedulablesTreeWidget() : _add_process_dialog_glade(Xml::create(GLADEDIR "/add-process-dialog.glade")) { _columns.add(_column); _model = TreeStore::create(_columns); set_model(_model); /** JUST A BIT OF DATA FOR TESTING **/ Gtk::TreeModel::Row row1 = *(_model->append()); row1[_column] = ustring("ciccio"); Gtk::TreeModel::Row row2 = *(_model->append()); row2[_column] = ustring("pippo"); append_column("schedulables", _column); /** 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 = "" " " // " " " " " " ""; _UIManager->add_ui_from_string(ui_info); _menu = dynamic_cast(_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(); set_headers_visible(false); } 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; } SchedulablesTreeWidget::~SchedulablesTreeWidget() {} void SchedulablesTreeWidget::update(const History& history) { } 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(); }