// src/startgui.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 "config.h" #include "gettext.h" #include "schedulables_tree_widget.hh" #include "simulation_widget.hh" #include "gui_builder.hh" #include "backend/history.hh" #include "backend/simulation.hh" #include #include #include #include #include #include #include using namespace sgpem; using Gnome::Glade::Xml; void test_me() { // A test for widget display: Simulation& sim = Simulation::get_instance(); sim.get_history().add_process("goofy", 0, 0); } GuiBuilder::GuiBuilder(const std::string& gladefile) : _refXml(Xml::create(gladefile)) { using namespace Gtk; Window& main_window = get_initial_window(); // Connect extra signals (decide where to do this... // here -- ugly -- derive widgets and then use // Glade::Xml::get_widget_derived -- better --) MenuItem* file_quit = NULL; _refXml->get_widget("MenuItem.File.Quit", file_quit); file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit)); // About dialog MenuItem* help_about = NULL; _refXml->get_widget("MenuItem.Help.About", help_about); AboutDialog* about_dialog = NULL; _refXml->get_widget("AboutDialog", about_dialog); //help_about->signal_activate().connect(sigc::mem_fun(*about_dialog, &Window::show)); help_about->signal_activate().connect(sigc::ptr_fun(test_me)); // Temporary code to test the Schedulables custom widget Expander* scheds_expander = NULL; _refXml->get_widget("SchedulablesExpander", scheds_expander); SchedulablesTreeWidget* scheds_widget = manage(new SchedulablesTreeWidget()); scheds_expander->add(*scheds_widget); // we have to remember to manually show custom added widgets: scheds_widget->show(); // Main simulation widget ScrolledWindow* simulation_window = NULL; _refXml->get_widget("SimulationScrolledWindow", simulation_window); SimulationWidget* simulation_widget = manage(new SimulationWidget()); simulation_window->add(*simulation_widget); simulation_widget->show(); } GuiBuilder::~GuiBuilder() {} Gtk::Window& GuiBuilder::get_initial_window() const { Gtk::Window* main_window = NULL; _refXml->get_widget("MainWindow", main_window); return *main_window; } void GuiBuilder::open_file(const std::string& filename) { // FIXME: to be written. // Debug line (erase me when done): std::cout << _("Filename to open: ") << filename << std::endl; }