From 5d837552c852a7de98dcb0f3d388818d3dfe43d7 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Sat, 2 Sep 2006 11:12:23 +0000 Subject: [PATCH] - 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 --- glade/main-window.glade | 1015 +++++++++++++------------------ src/gui_builder.cc | 43 +- src/gui_builder.hh | 5 + src/schedulables_tree_widget.cc | 2 +- 4 files changed, 463 insertions(+), 602 deletions(-) diff --git a/glade/main-window.glade b/glade/main-window.glade index edf9529..4c08e01 100644 --- a/glade/main-window.glade +++ b/glade/main-window.glade @@ -1,606 +1,425 @@ - - - + + + - - - SGPEMv2 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 800 - 600 - True - False - gtk-dialog-warning - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - True - False - - - - True - False - 0 - - - - True - GTK_PACK_DIRECTION_LTR - GTK_PACK_DIRECTION_LTR - - - - True - _File - True - - - - - - - True - gtk-open - True - - - - - - True - gtk-save - True - - - - - - True - gtk-save-as - True - - - - - - True - gtk-close - True - - - - - - True - - - - - - True - gtk-quit - True - - - - - - - - - - True - _Edit - True - - - - - - - True - gtk-preferences - True - - - - - - - - - - True - _Simulation - True - - - - - - - True - gtk-media-play - True - - - - - - True - gtk-media-pause - True - - - - - - True - gtk-media-stop - True - - - - - - - - - - - True - _Help - True - - - - - - - True - gtk-about - True - - - - - - - - - 0 - False - True - - - - - - True - GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_BOTH - True - True - - - - True - gtk-open - True - True - False - - - False - True - - - - - - True - gtk-save - True - True - False - - - False - True - - - - - - True - True - True - True - - - False - False - - - - - - True - Start the simulation - gtk-media-play - True - True - False - - - False - True - - - - - - True - False - gtk-media-pause - True - True - False - - - False - True - - - - - - True - False - gtk-media-stop - True - True - False - - - False - True - - - - - - True - True - True - True - - - False - False - - - - - - True - Scheduling Policy - True - gtk-convert - True - True - False - - - False - False - - - - - - True - True - True - True - - - False - False - - - - - - True - Resource Scheduling - True - gtk-select-color - True - True - False - - - False - False - - - - - 0 - False - True - - - - - - 1 - True - True - 200 - - - - True - - - - True - 0 - 0 - GTK_SHADOW_NONE - - - - True - 0 - 0 - 1 - 1 - 0 - 0 - 12 - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_OUT - GTK_CORNER_TOP_LEFT - - - - - - - - - - - - True - <i>Schedulables</i> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 2 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - True - False - - - - - - True - 0 - 0 - GTK_SHADOW_NONE - - - - True - 0 - 0 - 1 - 1 - 0 - 0 - 12 - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_OUT - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - - - - - - True - <i>Resources</i> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 0 - 2 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - True - False - - - - - False - False - - - - - - True - True - GTK_POLICY_ALWAYS - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - - - - True - True - - - - - 0 - True - True - - - - - - True - True - - - 0 - False - True - GTK_PACK_END - - - - - - True - <b>Ready queue: {</b> <b>}</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0 - 7 - 2 - PANGO_ELLIPSIZE_END - -1 - True - 0 - - - 0 - False - True - - - - - - - - False - Application Name - University of Padova, dept. of Pure and Applied Mathematics - An educational simulator for process scheduling policies in a monoprocessor computer. - SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the terms of the GNU General Public License; for details see file COPYING contained in the source package. - False - Giovanni Giacobbi <ggiacobb@studenti.math.unipd.it> + + SGPEMv2 + 800 + 600 + gtk-dialog-warning + + + True + + + True + + + True + _File + True + + + + + True + gtk-open + True + True + + + + + True + gtk-save + True + True + + + + + True + gtk-save-as + True + True + + + + + True + gtk-close + True + True + + + + + True + + + + + True + gtk-quit + True + True + + + + + + + + + True + _Edit + True + + + + + True + gtk-preferences + True + True + + + + + + + + + True + _Simulation + True + + + + + True + gtk-media-play + True + True + + + + + True + False + gtk-media-pause + True + True + + + + + True + False + gtk-media-stop + True + True + + + + + + True + + + + + True + True + Continuous mode + + + + + + + + + True + _Help + True + + + + + True + gtk-about + True + True + + + + + + + + + False + + + + + True + GTK_TOOLBAR_BOTH + + + True + gtk-open + + + + + True + gtk-save + + + + + True + + + + + True + gtk-media-play + Start the simulation + + + + + True + False + gtk-media-pause + + + + + True + False + gtk-media-stop + + + + + True + + + + + True + Scheduling Policy + True + gtk-convert + + + + + True + + + + + True + Resource Scheduling + True + gtk-select-color + + + + + False + 1 + + + + + True + True + 1 + 200 + + + True + + + True + 0,000000 + 0,000000 + GTK_SHADOW_NONE + + + True + 0,000000 + 0,000000 + 12 + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_OUT + + + + + + + + + + True + 0,000000 + 0,000000 + 2 + <i>Schedulables</i> + True + + + label_item + + + + + False + + + + + True + 0,000000 + 0,000000 + GTK_SHADOW_NONE + + + True + 0,000000 + 0,000000 + 12 + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_OUT + + + True + True + + + + + + + + + True + 0,000000 + 0,000000 + 2 + <i>Resources</i> + True + + + label_item + + + + + False + + + + + False + False + + + + + True + True + GTK_POLICY_AUTOMATIC + + + + + + + + 2 + + + + + True + 0,000000 + 0,000000 + 7 + 2 + <b>Ready queue: {</b> <b>}</b> + True + PANGO_ELLIPSIZE_END + True + + + False + 4 + + + + + True + + + False + GTK_PACK_END + 3 + + + + + + + University of Padova, dept. of Pure and Applied Mathematics + An educational simulator for process scheduling policies in a monoprocessor computer. + SGPEMv2 comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the terms of the GNU General Public License; for details see file COPYING contained in the source package. + Giovanni Giacobbi <ggiacobb@studenti.math.unipd.it> Filippo Paparella <ironpipp@gmail.com> Paolo Santi <psanti@studenti.math.unipd.it> Matteo Settenvini <matteo@member.fsf.org> Marco Trevisan <mtrevisa@studenti.math.unipd.it> Djina Verbanac <betalgez@yahoo.com> Luca Vezzaro <lvezzaro@studenti.math.unipd.it> - - - - - - True - False - 12 - - - - - - - - True - GTK_BUTTONBOX_END - - - 0 - False - True - GTK_PACK_END - - - - - - + + + + True + 12 + + + + + + True + GTK_BUTTONBOX_END + + + False + GTK_PACK_END + + + + + diff --git a/src/gui_builder.cc b/src/gui_builder.cc index a52c6dd..6b35024 100644 --- a/src/gui_builder.cc +++ b/src/gui_builder.cc @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -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(); } diff --git a/src/gui_builder.hh b/src/gui_builder.hh index 045ce27..8349522 100644 --- a/src/gui_builder.hh +++ b/src/gui_builder.hh @@ -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); diff --git a/src/schedulables_tree_widget.cc b/src/schedulables_tree_widget.cc index 7e9efbb..932cf5d 100644 --- a/src/schedulables_tree_widget.cc +++ b/src/schedulables_tree_widget.cc @@ -613,7 +613,7 @@ SchedulablesTreeWidget::markup_schedulable(const Schedulable& s) oss << "" << Markup::escape_text(s.get_name()) << "" - << _(", 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()