- Add check menu item to select simulation mode

- Connect also simulation menu items in SimulationController
- Fix typo in SchedulablesTreeWidget


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@993 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-02 11:12:23 +00:00
parent 3df5d38041
commit 5d837552c8
4 changed files with 463 additions and 602 deletions

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,7 @@
#include <gtkmm/menutoolbutton.h>
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/main.h>
#include <gtkmm/checkmenuitem.h>
#include <gtkmm/radiomenuitem.h>
#include <gtkmm/menuitem.h>
#include <gtkmm/radiobuttongroup.h>
@ -362,6 +363,17 @@ GuiBuilder::on_selected_resource_policy(ResourcePolicy* pol)
sbar->push(_("Selected resource policy ") + pol->get_name());
}
void
GuiBuilder::on_toggle_simulation_mode()
{
Gtk::CheckMenuItem* continuous_mode;
_refXml->get_widget("MenuItem.Simulation.ContinuousMode", continuous_mode);
if(continuous_mode->get_active() == true)
Simulation::get_instance().set_mode(Simulation::mode_continuous);
else
Simulation::get_instance().set_mode(Simulation::mode_step_by_step);
}
GuiBuilder::GuiBuilder(const std::string& gladefile)
: _refXml(Xml::create(gladefile)), _controller(Simulation::get_instance(), _refXml)
@ -386,9 +398,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
file_saveas->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_file_saveas_activate));
// Connect extra signals (decide where to do this...
// here -- ugly -- derive widgets and then use
// Glade::Xml::get_widget_derived -- better --)
// ---------------- Menu items ------------------
// Note: the Play, Pause and Stop menu items are already managed by sgpem::SimulationController.
MenuItem* file_quit = NULL;
_refXml->get_widget("MenuItem.File.Quit", file_quit);
file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit));
@ -398,6 +411,10 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
_refXml->get_widget("MenuItem.Edit.Preferences", edit_preferences);
edit_preferences->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_edit_preferences_activate));
CheckMenuItem* continuous_mode;
_refXml->get_widget("MenuItem.Simulation.ContinuousMode", continuous_mode);
continuous_mode->signal_toggled().connect(sigc::mem_fun(*this, &GuiBuilder::on_toggle_simulation_mode));
// ---------------- Toolbar buttons ------------------
@ -492,9 +509,17 @@ SimulationController::SimulationController(Simulation& simulation, Glib::RefPtr<
refXml->get_widget("ToolBar.Pause", _toolbt_pause);
refXml->get_widget("ToolBar.Stop", _toolbt_stop);
refXml->get_widget("MenuItem.Simulation.Play", _menuit_start);
refXml->get_widget("MenuItem.Simulation.Pause", _menuit_pause);
refXml->get_widget("MenuItem.Simulation.Stop", _menuit_stop);
_toolbt_start->signal_clicked().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_run));
_toolbt_pause->signal_clicked().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_pause));
_toolbt_stop->signal_clicked().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_stop));
_menuit_start->signal_activate().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_run));
_menuit_pause->signal_activate().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_pause));
_menuit_stop->signal_activate().connect(sigc::mem_fun(*this, &SimulationController::on_simulation_stop));
}
@ -512,6 +537,10 @@ SimulationController::on_simulation_run()
_toolbt_pause->set_sensitive(true);
_toolbt_stop->set_sensitive(true);
_menuit_start->set_sensitive(false);
_menuit_pause->set_sensitive(true);
_menuit_stop->set_sensitive(true);
_break_requested = false;
// Used instead of simply calling "_sim.run()" to
// have exception handling only in one place:
@ -527,6 +556,10 @@ SimulationController::on_simulation_pause()
_toolbt_pause->set_sensitive(false);
_toolbt_stop->set_sensitive(true);
_menuit_start->set_sensitive(true);
_menuit_pause->set_sensitive(false);
_menuit_stop->set_sensitive(true);
_break_requested = true;
_sim.pause();
}
@ -540,6 +573,10 @@ SimulationController::on_simulation_stop()
_toolbt_pause->set_sensitive(false);
_toolbt_stop->set_sensitive(false);
_menuit_start->set_sensitive(true);
_menuit_pause->set_sensitive(false);
_menuit_stop->set_sensitive(false);
_break_requested = true;
_sim.stop();
}

View File

@ -68,6 +68,10 @@ namespace sgpem
Gtk::ToolButton* _toolbt_start;
Gtk::ToolButton* _toolbt_pause;
Gtk::ToolButton* _toolbt_stop;
Gtk::MenuItem* _menuit_start;
Gtk::MenuItem* _menuit_pause;
Gtk::MenuItem* _menuit_stop;
};
@ -88,6 +92,7 @@ namespace sgpem
void on_configure_resource_policy();
void on_selected_cpu_policy(CPUPolicy* pol);
void on_selected_resource_policy(ResourcePolicy* pol);
void on_toggle_simulation_mode();
void populate_with_cpu_policies(Gtk::Menu& menu);
void populate_with_resource_policies(Gtk::Menu& menu);

View File

@ -613,7 +613,7 @@ SchedulablesTreeWidget::markup_schedulable(const Schedulable& s)
oss << "<small><span foreground=\""
<< GlobalPreferences::get_instance().get_schedulable_color(s.get_state())
<< "\"><b>" << Markup::escape_text(s.get_name()) << "</b></span>"
<< _(", arrived at: ") << s.get_arrival_time()
<< _(", arrives at: ") << s.get_arrival_time()
<< _(", base priority: ") << s.get_base_priority()
<< _(", elapsed time: ") << s.get_elapsed_time()
<< _(", current priority: ") << s.get_current_priority()