2006-01-27 18:57:53 +01:00
|
|
|
// src/startgui.cc - Copyright 2005, 2006, University
|
2006-01-26 19:31:23 +01:00
|
|
|
// 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"
|
|
|
|
|
2006-07-12 11:24:57 +02:00
|
|
|
#include "schedulables_widget.hh"
|
2006-07-06 14:23:29 +02:00
|
|
|
#include "gui_builder.hh"
|
2006-01-26 19:31:23 +01:00
|
|
|
|
2006-08-02 15:48:26 +02:00
|
|
|
#include "backend/history.hh"
|
|
|
|
#include "backend/simulation.hh"
|
|
|
|
|
2006-07-05 17:16:58 +02:00
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
#include <gtkmm/aboutdialog.h>
|
2006-07-12 11:24:57 +02:00
|
|
|
#include <gtkmm/expander.h>
|
2006-01-26 19:31:23 +01:00
|
|
|
#include <gtkmm/main.h>
|
2006-07-05 16:37:11 +02:00
|
|
|
#include <gtkmm/menuitem.h>
|
|
|
|
|
2006-07-06 11:49:35 +02:00
|
|
|
#include <iostream>
|
2006-01-26 19:31:23 +01:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
using namespace sgpem;
|
|
|
|
using Gnome::Glade::Xml;
|
2006-07-05 16:37:11 +02:00
|
|
|
|
2006-08-03 17:43:21 +02:00
|
|
|
void
|
|
|
|
test_me()
|
|
|
|
{
|
|
|
|
// A test for widget display:
|
|
|
|
Simulation& sim = Simulation::get_instance();
|
|
|
|
sim.get_history().add_process("goofy", 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-07-05 16:37:11 +02:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
GuiBuilder::GuiBuilder(const std::string& gladefile)
|
|
|
|
: _refXml(Xml::create(gladefile))
|
|
|
|
{
|
|
|
|
using namespace Gtk;
|
2006-06-29 10:44:30 +02:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
Window& main_window = get_initial_window();
|
2006-06-29 10:44:30 +02:00
|
|
|
|
2006-07-05 16:37:11 +02:00
|
|
|
// 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;
|
2006-07-06 14:23:29 +02:00
|
|
|
_refXml->get_widget("MenuItem.File.Quit", file_quit);
|
2006-07-06 13:26:23 +02:00
|
|
|
file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit));
|
2006-02-22 23:45:06 +01:00
|
|
|
|
2006-07-05 17:16:58 +02:00
|
|
|
// About dialog
|
|
|
|
MenuItem* help_about = NULL;
|
2006-07-06 14:23:29 +02:00
|
|
|
_refXml->get_widget("MenuItem.Help.About", help_about);
|
2006-07-05 17:16:58 +02:00
|
|
|
AboutDialog* about_dialog = NULL;
|
2006-07-06 14:23:29 +02:00
|
|
|
_refXml->get_widget("AboutDialog", about_dialog);
|
2006-08-03 17:43:21 +02:00
|
|
|
//help_about->signal_activate().connect(sigc::mem_fun(*about_dialog, &Window::show));
|
|
|
|
help_about->signal_activate().connect(sigc::ptr_fun(test_me));
|
2006-07-12 11:24:57 +02:00
|
|
|
|
|
|
|
// Temporary code to test the Schedulables custom widget
|
|
|
|
Expander* scheds_expander = NULL;
|
|
|
|
_refXml->get_widget("SchedulablesExpander", scheds_expander);
|
|
|
|
SchedulablesWidget* scheds_widget = manage(new SchedulablesWidget());
|
|
|
|
scheds_expander->add(*scheds_widget);
|
|
|
|
// we have to remember to manually show custom added widgets:
|
|
|
|
scheds_widget->show();
|
2006-08-02 15:48:26 +02:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiBuilder::~GuiBuilder()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-07-06 11:49:35 +02:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
Gtk::Window&
|
|
|
|
GuiBuilder::get_initial_window() const
|
|
|
|
{
|
|
|
|
Gtk::Window* main_window = NULL;
|
|
|
|
_refXml->get_widget("MainWindow", main_window);
|
|
|
|
return *main_window;
|
2006-01-26 19:31:23 +01:00
|
|
|
}
|
2006-02-19 23:36:24 +01:00
|
|
|
|
2006-07-06 14:23:29 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|