From 35523c6cf4c8f1a5cbda634161e751f33d7da7ef Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 31 Dec 2009 15:59:56 +0000 Subject: [PATCH] Fix some header includes. Fix one-liner bug that prevented the Cairo widgets from showing. Sometimes, you've an obvious bug under your nose, but you prefer your pride instead of running gdb. Oh, well. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1350 3ecf2c5c-341e-0410-92b4-d18e462d057c --- TODO | 4 -- src/cairo_widget.cc | 28 ++++++------- src/cairo_widget.hh | 15 +------ src/configure_policy_dialog.hh | 4 +- src/graphical_preferences_editor.hh | 4 +- src/gui_builder.hh | 4 +- src/holt_container_window.hh | 2 +- src/holt_widget.hh | 8 ++-- src/jump_to_dialog.hh | 4 +- src/ready_queue_widget.hh | 4 +- src/resources_widget.hh | 4 +- src/schedulables_statistics_widget.hh | 4 +- src/schedulables_tree_widget.hh | 8 ++-- src/simulation_controller.hh | 4 +- src/simulation_statistics_widget.hh | 4 +- src/simulation_widget.cc | 20 +-------- src/simulation_widget.hh | 15 +------ src/statistics_container_window.hh | 3 +- src/testsuite/test-cairo_widget.cc | 5 +-- .../test-global_preferences_serialization.cc | 6 ++- src/testsuite/test-history.cc | 8 ++-- src/testsuite/test-holt_widget.cc | 41 ++++++++++--------- src/testsuite/test-key_file.cc | 2 +- src/testsuite/test-parse_command.cc | 26 ++++++------ src/testsuite/test-simulation_widget.cc | 35 ++++++++-------- src/testsuite/test-statistics.cc | 27 ++++++------ src/testsuite/test-stepforward.cc | 30 ++++++-------- src/text_simulation.hh | 6 +-- 28 files changed, 130 insertions(+), 195 deletions(-) diff --git a/TODO b/TODO index d033c8d..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,4 +0,0 @@ -- fix nasty bug that prevents all cairowidgets from showing up -- Check for simulationwidget deprecat. meth. -- check headers for #includes with <> instead of "" -- Report bug for presence of PKG, VERSION, etc. macros inside cairomm-config.h diff --git a/src/cairo_widget.cc b/src/cairo_widget.cc index 034cd86..0aa6a9e 100644 --- a/src/cairo_widget.cc +++ b/src/cairo_widget.cc @@ -36,8 +36,9 @@ CairoWidget::CairoWidget() : Glib::ObjectBase("sgpem_CairoWidget"), Gtk::Widget(), _draw_w(1), _draw_h(1), - _client_w(0), _client_h(0), _pixmap_w(0), _pixmap_h(0), - _need_redraw(true), _scaling_mode(scaling_none), + _client_w(0), _client_h(0), + _pixmap_w(0), _pixmap_h(0), + _need_redraw(true), _scaling_mode(scaling_none), _buf(NULL) { set_flags(Gtk::NO_WINDOW); @@ -78,7 +79,7 @@ CairoWidget::on_realize() Gtk::Widget::on_realize(); ensure_style(); - if (!_ref_gdk_window) return; + if (_ref_gdk_window) return; GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); @@ -89,22 +90,22 @@ CairoWidget::on_realize() attributes.y = alloc.get_y(); attributes.width = alloc.get_width(); attributes.height = alloc.get_height(); + attributes.wclass = GDK_INPUT_OUTPUT; attributes.event_mask = get_events() | GDK_EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; _client_w = alloc.get_width(); - _client_h = alloc.get_height(); - + _client_h = alloc.get_height(); static const gint attributes_mask = Gdk::WA_X | Gdk::WA_Y; - _ref_gdk_window = Gdk::Window::create(get_window(), - &attributes, - attributes_mask); + _ref_gdk_window = Gdk::Window::create(get_window() /* parent */, + &attributes, attributes_mask); unset_flags(Gtk::NO_WINDOW); set_window(_ref_gdk_window); + _ref_gdk_window->set_user_data(gobj()); } @@ -125,8 +126,8 @@ CairoWidget::on_size_allocate(const Gtk::Allocation& allocation) if (!_ref_gdk_window) return; - get_window()->move_resize(allocation.get_x(), allocation.get_y(), - allocation.get_width(), allocation.get_height()); + _ref_gdk_window->move_resize(allocation.get_x(), allocation.get_y(), + allocation.get_width(), allocation.get_height()); // the widget's dimension are saved for futher use _client_w = allocation.get_width(); @@ -196,15 +197,14 @@ CairoWidget::on_expose_event(GdkEventExpose* event) // allocate the pixmap _buf = Gdk::Pixmap::create(_ref_gdk_window, _pixmap_w, _pixmap_h); } - // Draw the widget background as the first thing. // I've seen this is how it's done in the very Gtk+ toolkit // for the GtkProgressBar widget. - GtkStyle* gStyle = get_style()->gobj(); - gtk_paint_box(gStyle, _buf->gobj(), + Glib::RefPtr style = get_style(); + gtk_paint_box(style->gobj(), _buf->gobj(), GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, - NULL, (GtkWidget*)this->gobj(), "through", + NULL, GTK_WIDGET (this->gobj()), "through", 0, 0, _client_w, _client_h); // here the cairo context is created diff --git a/src/cairo_widget.hh b/src/cairo_widget.hh index 76ffa40..dffac41 100644 --- a/src/cairo_widget.hh +++ b/src/cairo_widget.hh @@ -179,10 +179,6 @@ namespace sgpem * See gtkmm documentation for more informations. */ virtual bool on_expose_event(GdkEventExpose* event); - /* - to delete asap - virtual bool on_button_press_event(GdkEventButton* event); - */ /** * \brief Client area drawing method. @@ -220,15 +216,6 @@ namespace sgpem */ void calc_scale_factors(); - /* - I don't know the meaning of these definition! - Paolo - typedef Gdk::Rectangle area_t; - typedef sigc::mem_functor0 method0_t; - typedef std::pair area_callback_t; - typedef std::vector areas_vect_t; - */ - /** * \brief Calculated width of drawing. */ @@ -283,7 +270,7 @@ namespace sgpem /** * \brief Offscreen pixmap used for double-buffering. */ - Glib::RefPtr _buf; + Glib::RefPtr _buf; /** * diff --git a/src/configure_policy_dialog.hh b/src/configure_policy_dialog.hh index d234e1e..7039be2 100644 --- a/src/configure_policy_dialog.hh +++ b/src/configure_policy_dialog.hh @@ -21,9 +21,7 @@ #ifndef CONFIGURE_POLICY_DIALOG_HH #define CONFIGURE_POLICY_DIALOG_HH 1 - -#include - +#include "sgpemv2/policy_parameters.hh" #include #include diff --git a/src/graphical_preferences_editor.hh b/src/graphical_preferences_editor.hh index f03917b..9d317b7 100644 --- a/src/graphical_preferences_editor.hh +++ b/src/graphical_preferences_editor.hh @@ -21,9 +21,7 @@ #ifndef GRAPHICAL_PREFERENCES_EDITOR_HH #define GRAPHICAL_PREFERENCES_EDITOR_HH 1 - -#include - +#include "sgpemv2/global_preferences.hh" #include #include diff --git a/src/gui_builder.hh b/src/gui_builder.hh index 177fefb..4508667 100644 --- a/src/gui_builder.hh +++ b/src/gui_builder.hh @@ -26,8 +26,8 @@ #include "statistics_container_window.hh" #include "simulation_widget.hh" -#include -#include +#include "sgpemv2/cpu_policy.hh" +#include "sgpemv2/resource_policy.hh" #include "simulation_controller.hh" diff --git a/src/holt_container_window.hh b/src/holt_container_window.hh index b61fe3d..d974986 100644 --- a/src/holt_container_window.hh +++ b/src/holt_container_window.hh @@ -27,7 +27,7 @@ #include "cairo_widget.hh" #include "holt_widget.hh" -#include +#include "sgpemv2/simulation.hh" #include diff --git a/src/holt_widget.hh b/src/holt_widget.hh index 67d9ccc..799c892 100644 --- a/src/holt_widget.hh +++ b/src/holt_widget.hh @@ -23,10 +23,10 @@ #include "cairo_widget.hh" -#include -#include -#include -#include +#include "sgpemv2/history_observer.hh" +#include "sgpemv2/request.hh" +#include "sgpemv2/sub_request.hh" +#include "sgpemv2/simulation_observer.hh" #include diff --git a/src/jump_to_dialog.hh b/src/jump_to_dialog.hh index 005e1b3..ed10bf7 100644 --- a/src/jump_to_dialog.hh +++ b/src/jump_to_dialog.hh @@ -21,9 +21,7 @@ #ifndef JUMP_TO_DIALOG_HH #define JUMP_TO_DIALOG_HH 1 - - -#include +#include "sgpemv2/simulation_observer.hh" #include #include diff --git a/src/ready_queue_widget.hh b/src/ready_queue_widget.hh index 67d4473..773080a 100644 --- a/src/ready_queue_widget.hh +++ b/src/ready_queue_widget.hh @@ -21,9 +21,7 @@ #ifndef READY_QUEUE_WIDGET_HH #define READY_QUEUE_WIDGET_HH 1 - - -#include +#include "sgpemv2/history_observer.hh" #include diff --git a/src/resources_widget.hh b/src/resources_widget.hh index f16edaf..2e5a53b 100644 --- a/src/resources_widget.hh +++ b/src/resources_widget.hh @@ -26,8 +26,6 @@ namespace sgpem class Resource; } - - #include #include #include @@ -36,7 +34,7 @@ namespace sgpem #include #include -#include +#include "sgpemv2/history_observer.hh" namespace sgpem { diff --git a/src/schedulables_statistics_widget.hh b/src/schedulables_statistics_widget.hh index 0afa212..897fce9 100644 --- a/src/schedulables_statistics_widget.hh +++ b/src/schedulables_statistics_widget.hh @@ -21,10 +21,8 @@ #ifndef SCHEDULABLE_STATISTICS_WIDGET_HH #define SCHEDULABLE_STATISTICS_WIDGET_HH 1 - - #include "cairo_widget.hh" -#include +#include "sgpemv2/history_observer.hh" #include #include diff --git a/src/schedulables_tree_widget.hh b/src/schedulables_tree_widget.hh index bad15bb..550e740 100644 --- a/src/schedulables_tree_widget.hh +++ b/src/schedulables_tree_widget.hh @@ -30,7 +30,9 @@ namespace sgpem class Request; } - +#include "sgpemv2/history_observer.hh" +#include "sgpemv2/schedulable.hh" +#include "sgpemv2/request.hh" #include #include @@ -39,10 +41,6 @@ namespace sgpem #include #include -#include -#include -#include - #include namespace sgpem diff --git a/src/simulation_controller.hh b/src/simulation_controller.hh index 7eb3b01..8832fa3 100644 --- a/src/simulation_controller.hh +++ b/src/simulation_controller.hh @@ -21,9 +21,7 @@ #ifndef SIMULATION_CONTROLLER_HH #define SIMULATION_CONTROLLER_HH 1 - - -#include +#include "sgpemv2/simulation_observer.hh" #include #include diff --git a/src/simulation_statistics_widget.hh b/src/simulation_statistics_widget.hh index 9cb9c85..8d7ab0a 100644 --- a/src/simulation_statistics_widget.hh +++ b/src/simulation_statistics_widget.hh @@ -21,9 +21,7 @@ #ifndef SIMULATION_STATISTICS_WIDGET_HH #define SIMULATION_STATISTICS_WIDGET_HH 1 - - -#include +#include "sgpemv2/history_observer.hh" #include #include diff --git a/src/simulation_widget.cc b/src/simulation_widget.cc index cb3136d..8a3e045 100644 --- a/src/simulation_widget.cc +++ b/src/simulation_widget.cc @@ -48,20 +48,13 @@ using namespace Glib; SimulationWidget::SimulationWidget(Simulation& simulation) : Glib::ObjectBase("sgpem_SimulationWidget"), - SimulationObserver(), HistoryObserver(), CairoWidget(), _simulation(&simulation), _x_unit(10), _y_unit(10), _n_proc(0), _n_thr(0) { - // Register this SimulationObserver: - _simulation->attach(*this); - - // Register this HistoryObserver: - _simulation->get_history().attach(*this); - - // count_elements(); + simulation.get_history().attach(*this); // define top margin in y units _yu_top_margin = 1.0; @@ -85,7 +78,7 @@ SimulationWidget::SimulationWidget(Simulation& simulation) _yu_thread_bar_height = 1.0; _partial_redraw = false; - _last_drawn = 0; + _last_drawn = 0; } @@ -93,9 +86,6 @@ SimulationWidget::~SimulationWidget() { // Unregister this HistoryObserver: _simulation->get_history().detach(*this); - - // Unregister this SimulationObserver: - _simulation->detach(*this); } void @@ -108,12 +98,6 @@ SimulationWidget::on_realize() gdk_win->set_events(gdk_win->get_events() | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK); } -void -SimulationWidget::update(const Simulation& /* changed_simulation */ ) -{ - // FIXME: DEPRECATED. Does nothing. -} - void SimulationWidget::update(const History& /* changed_history */ ) { diff --git a/src/simulation_widget.hh b/src/simulation_widget.hh index e9ab3b0..7e14f4a 100644 --- a/src/simulation_widget.hh +++ b/src/simulation_widget.hh @@ -49,16 +49,14 @@ namespace sgpem * * At the bottom of the graph there is a time line ruler. * - * This class implements a SimulationObserver and HistoryObserver + * This class implements an HistoryObserver * to have an update signal (and related update) every simulation step. * - * \deprecated The class should implement only HistoryObserver - * * \see SimulationObserver * \see HistoryObserver */ class SimulationWidget - : public SimulationObserver, public HistoryObserver, public CairoWidget + : public HistoryObserver, public CairoWidget { public: /** @@ -75,15 +73,6 @@ namespace sgpem */ virtual ~SimulationWidget(); - /** - * \brief SimulationObserver's update method redefinition. - * - * \deprecated Actually is a dummy method. - * - * \param changed_simulation the observed Simulation - */ - virtual void update(const Simulation& changed_simulation); - /** * \brief HistoryObserver's update method redefinition. * diff --git a/src/statistics_container_window.hh b/src/statistics_container_window.hh index f671155..680186c 100644 --- a/src/statistics_container_window.hh +++ b/src/statistics_container_window.hh @@ -24,10 +24,9 @@ #include "schedulables_statistics_widget.hh" #include "simulation_statistics_widget.hh" - #include "gettext.h" -#include +#include "sgpemv2/simulation.hh" #include #include diff --git a/src/testsuite/test-cairo_widget.cc b/src/testsuite/test-cairo_widget.cc index 363c224..b7a0f22 100644 --- a/src/testsuite/test-cairo_widget.cc +++ b/src/testsuite/test-cairo_widget.cc @@ -18,13 +18,10 @@ // along with SGPEMv2. If not, see http://www.gnu.org/licenses/. - - #include "cairo_widget.hh" #include "cairo_elements.hh" #include "gettext.h" - #include #include #include @@ -140,7 +137,7 @@ TestWidget::draw_widget(Cairo::RefPtr& ctx) } ctx->move_to(10, 10); ctx->show_text(msg); - msg = "clic to change mode..."; + msg = "click to change mode..."; ctx->move_to(10, 30); ctx->show_text(msg); } diff --git a/src/testsuite/test-global_preferences_serialization.cc b/src/testsuite/test-global_preferences_serialization.cc index 9673882..83a2509 100644 --- a/src/testsuite/test-global_preferences_serialization.cc +++ b/src/testsuite/test-global_preferences_serialization.cc @@ -22,8 +22,10 @@ * and nothing else. */ -#include "glibmm/ustring.h" -#include +#include "sgpemv2/global_preferences.hh" + +#include + #include #include diff --git a/src/testsuite/test-history.cc b/src/testsuite/test-history.cc index 7035ed4..33e877a 100644 --- a/src/testsuite/test-history.cc +++ b/src/testsuite/test-history.cc @@ -24,14 +24,16 @@ #include "gettext.h" +#include "concrete_environment.hh" +#include "concrete_history.hh" + +#include "sgpemv2/history_observer.hh" + #include #include #include -#include "concrete_environment.hh" -#include "concrete_history.hh" -#include using namespace sgpem; using namespace std; diff --git a/src/testsuite/test-holt_widget.cc b/src/testsuite/test-holt_widget.cc index b54b3d9..97184c9 100644 --- a/src/testsuite/test-holt_widget.cc +++ b/src/testsuite/test-holt_widget.cc @@ -24,6 +24,27 @@ #include "gettext.h" +#include "cairo_elements.hh" +#include "cairo_widget.hh" +#include "holt_container_window.hh" +#include "holt_widget.hh" +#include "simulation_widget.hh" + +#include "sgpemv2/cpu_policies_gatekeeper.hh" +#include "sgpemv2/cpu_policy.hh" +#include "sgpemv2/cpu_policy_manager.hh" +#include "sgpemv2/resource_policies_gatekeeper.hh" +#include "sgpemv2/resource_policy.hh" +#include "sgpemv2/resource_policy_manager.hh" + +#include "sgpemv2/history_observer.hh" +#include "sgpemv2/scheduler.hh" +#include "sgpemv2/simulation.hh" +#include "sgpemv2/simulation_observer.hh" +#include "sgpemv2/process.hh" +#include "sgpemv2/resource.hh" +#include "sgpemv2/thread.hh" + #include #include #include @@ -39,26 +60,6 @@ #include #include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "cairo_elements.hh" -#include "cairo_widget.hh" -#include "holt_container_window.hh" -#include "holt_widget.hh" -#include "simulation_widget.hh" - using namespace sgpem; using namespace std; using Glib::ustring; diff --git a/src/testsuite/test-key_file.cc b/src/testsuite/test-key_file.cc index c64899b..d517577 100644 --- a/src/testsuite/test-key_file.cc +++ b/src/testsuite/test-key_file.cc @@ -21,7 +21,7 @@ /* This executable tests for workingness of the save preferences method, * and nothing else. */ -#include +#include "sgpemv2/key_file.hh" #include diff --git a/src/testsuite/test-parse_command.cc b/src/testsuite/test-parse_command.cc index bbc2879..100b58a 100644 --- a/src/testsuite/test-parse_command.cc +++ b/src/testsuite/test-parse_command.cc @@ -21,27 +21,27 @@ /* This executable tests for workingness of the parseCommand method in the * classTextSimulation class and the StandardIO class. */ -#include "standard_io.hh" -#include "text_simulation.hh" - -#include -#include - #include "gettext.h" -#include "glibmm/ustring.h" - -#include -#include - #include "backend/static_process.hh" #include "backend/slice.hh" #include "backend/observed_subject.hh" -#include #include "backend/dynamic_schedulable.hh" -#include +#include "sgpemv2/ready_queue.hh" +#include "sgpemv2/templates/smartp.tcc" + +#include "standard_io.hh" +#include "text_simulation.hh" + +#include + +#include +#include +#include +#include + namespace sgpem { diff --git a/src/testsuite/test-simulation_widget.cc b/src/testsuite/test-simulation_widget.cc index 841ff2f..41b725c 100644 --- a/src/testsuite/test-simulation_widget.cc +++ b/src/testsuite/test-simulation_widget.cc @@ -24,6 +24,24 @@ #include "gettext.h" +#include "sgpemv2/cpu_policies_gatekeeper.hh" +#include "sgpemv2/cpu_policy.hh" +#include "sgpemv2/cpu_policy_manager.hh" +#include "sgpemv2/resource_policies_gatekeeper.hh" +#include "sgpemv2/resource_policy.hh" +#include "sgpemv2/resource_policy_manager.hh" +#include "sgpemv2/history_observer.hh" +#include "sgpemv2/scheduler.hh" +#include "sgpemv2/simulation.hh" +#include "sgpemv2/simulation_observer.hh" +#include "sgpemv2/process.hh" +#include "sgpemv2/resource.hh" +#include "sgpemv2/thread.hh" + +#include "cairo_elements.hh" +#include "cairo_widget.hh" +#include "simulation_widget.hh" + #include #include #include @@ -38,23 +56,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cairo_elements.hh" -#include "cairo_widget.hh" -#include "simulation_widget.hh" - using namespace sgpem; using namespace std; using Glib::ustring; diff --git a/src/testsuite/test-statistics.cc b/src/testsuite/test-statistics.cc index ff8f899..abaf2b2 100644 --- a/src/testsuite/test-statistics.cc +++ b/src/testsuite/test-statistics.cc @@ -24,23 +24,22 @@ #include "config.h" #include "gettext.h" -#include +#include #include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "sgpemv2/simulation.hh" +#include "sgpemv2/cpu_policies_gatekeeper.hh" +#include "sgpemv2/resource_policies_gatekeeper.hh" +#include "sgpemv2/cpu_policy_manager.hh" +#include "sgpemv2/resource_policy_manager.hh" +#include "sgpemv2/cpu_policy.hh" +#include "sgpemv2/resource_policy.hh" +#include "sgpemv2/plugin_manager.hh" +#include "sgpemv2/statistics.hh" +#include "sgpemv2/process_statistics.hh" +#include "sgpemv2/thread_statistics.hh" +#include "sgpemv2/module.hh" #include #include diff --git a/src/testsuite/test-stepforward.cc b/src/testsuite/test-stepforward.cc index bdbd8c6..cad9b05 100644 --- a/src/testsuite/test-stepforward.cc +++ b/src/testsuite/test-stepforward.cc @@ -21,28 +21,24 @@ /* This executable tests for workingness of the stepForward method, * and nothing else. */ +#include "gettext.h" +#include "backend/static_process.hh" +#include "backend/observed_subject.hh" +#include "backend/dynamic_schedulable.hh" -#include // ?? +#include "sgpemv2/ready_queue.hh" +#include "sgpemv2/scheduler.hh" +#include "sgpemv2/user_interrupt_exception.hh" + +#include "sgpemv2/templates/smartp.tcc" + +#include +#include #include #include -#include "gettext.h" -#include "glibmm/ustring.h" -#include -#include -#include "backend/static_process.hh" -#include "backend/observed_subject.hh" -#include -#include "backend/dynamic_schedulable.hh" - -#include -#include - -#include - -#include - +#include namespace sgpem { diff --git a/src/text_simulation.hh b/src/text_simulation.hh index daa44cd..7fac9b3 100644 --- a/src/text_simulation.hh +++ b/src/text_simulation.hh @@ -24,9 +24,9 @@ #include "gettext.h" -#include -#include -#include +#include "sgpemv2/simulation.hh" +#include "sgpemv2/simulation_observer.hh" +#include "sgpemv2/string_utils.hh" #include #include