From cfd7a025db9e0ad5747ea92591a20c029d9bd155 Mon Sep 17 00:00:00 2001 From: matrevis Date: Tue, 15 Aug 2006 17:33:47 +0000 Subject: [PATCH] - Added a best-effort preferences dialog: the user may now add plugin directories, policy directories, and set the simulation speed. - Added some menu voice to the main window. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@872 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 3 + glade/configure-dialog.glade | 892 +++++++++++++++++----------- glade/main-window.glade | 864 ++++++++++++++++++--------- src/backend/global_preferences.cc | 2 +- src/graphical_preferences_editor.cc | 206 +++++++ src/graphical_preferences_editor.hh | 83 +++ src/gui_builder.cc | 31 +- src/gui_builder.hh | 1 + 8 files changed, 1449 insertions(+), 633 deletions(-) create mode 100644 src/graphical_preferences_editor.cc create mode 100644 src/graphical_preferences_editor.hh diff --git a/Makefile.am b/Makefile.am index 225721d..3664d03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -291,6 +291,7 @@ sgpemv2_LDADD = \ sgpemv2_SOURCES = \ src/cairo_elements.cc \ src/cairo_widget.cc \ + src/graphical_preferences_editor.cc \ src/gui_builder.cc \ src/main.cc \ src/parse_opts.cc \ @@ -301,6 +302,7 @@ sgpemv2_SOURCES = \ noinst_HEADERS += \ src/cairo_elements.hh \ src/cairo_widget.hh \ + src/graphical_preferences_editor.hh \ src/gui_builder.hh \ src/main.hh \ src/parse_opts.hh \ @@ -315,6 +317,7 @@ glade_DATA = \ glade/add-request-dialog.glade \ glade/add-resource-dialog.glade \ glade/add-thread-dialog.glade \ + glade/configure-dialog.glade \ glade/main-window.glade # ############################################################ diff --git a/glade/configure-dialog.glade b/glade/configure-dialog.glade index ee67f62..2c2145f 100644 --- a/glade/configure-dialog.glade +++ b/glade/configure-dialog.glade @@ -6,10 +6,12 @@ 0 True - Configure SGPEMv2 + SGPEMv2 Preferences GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_MOUSE + GTK_WIN_POS_CENTER_ON_PARENT True + 500 + 300 True False True @@ -30,31 +32,18 @@ True - GTK_BUTTONBOX_SPREAD + GTK_BUTTONBOX_END - + True True True - gtk-cancel + gtk-close True GTK_RELIEF_NORMAL True - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 + -7 @@ -71,92 +60,27 @@ True True True - True + False GTK_POS_TOP False False + 5 True False - 0 + 5 - - True - True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - 0 - True - True - - - - - False - True - - - - - - True - Plugins - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - - 6 + True 0 0.5 - GTK_SHADOW_IN + GTK_SHADOW_NONE - + 6 True 0.5 @@ -169,210 +93,26 @@ 0 - + True - False - 10 + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - + True + False + False + True + False + False + False - - 0 - True - True - - - - - - True - False - 10 - - - - 100 - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-open - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Add - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - - 100 - True - True - GTK_RELIEF_NORMAL - True - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-remove - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Remove - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - - - - 0 - False - True - @@ -380,9 +120,9 @@ - + True - <b>Additional Plugin Directories</b> + <b>Loaded Plugins</b> False True GTK_JUSTIFY_LEFT @@ -410,15 +150,522 @@ - + True - <b>PLEASE! -PLEASE! -TELL ME -THERE IS SOME OTHER OPTION TO PUT HERE...</b> + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 10 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 4 + + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + + + + True + False + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + + 3 + False + False + GTK_PACK_END + + + + + + + + + + True + <b>Additional Plugin Directories</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.479999989271 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + False + True + + + + + + True + Plugins + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 5 + True + False + 5 + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + + + + + + True + <b>Loaded Policies</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.479999989271 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + 6 + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 10 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 4 + + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + + + + True + False + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + + 3 + False + False + GTK_PACK_END + + + + + + + + + + True + <b>Additional Policies Directories</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.479999989271 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + False + True + + + + + + True + Policies + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + True + True + 0 + + + + 5 + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + Simulation step speed (milliseconds) + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + True + False + + + + + + True + True + 2 + 0 + True + GTK_UPDATE_IF_VALID + True + False + 1000 0 9999 100 500 500 + + + 0 + True + False + + + + + + + + + + True + <b>Simulation speed</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + False - True - GTK_JUSTIFY_CENTER + False + GTK_JUSTIFY_LEFT False False 0.5 @@ -444,56 +691,9 @@ THERE IS SOME OTHER OPTION TO PUT HERE...</b> - + True - Startup - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - <b>FILL ME IN...</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - False - True - - - - - - True - Other(?) + Speed False False GTK_JUSTIFY_LEFT diff --git a/glade/main-window.glade b/glade/main-window.glade index a37805a..d6b5e96 100644 --- a/glade/main-window.glade +++ b/glade/main-window.glade @@ -1,294 +1,592 @@ - - - + + + - - 800 - 600 - - - True - - - True - - - True - _File - True - - - True - - - True - gtk-quit - True - True - - - - - - - - - True - _Help - True - - - True - - - True - gtk-about - True - True - - - - - - - - - False - - - - - True - GTK_TOOLBAR_BOTH - - - True - gtk-open - - - - - True - gtk-save - - - - - True - - - - - True - False - gtk-media-play - - - - - 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 - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - - - True - - - True - 3 - - - True - True - True - - - - - - True - 0,000000 - 0,000000 - Schedulables - - - label_item - - - - - - - True - True - True - - - - - - True - 0,000000 - 0,000000 - Resources - - - label_item - - - - - 1 - - - - - True - True - - - - - - True - 0,000000 - 0,000000 - Requests - - - label_item - - - - - False - 2 - - - - - - - - - - - True - True - GTK_POLICY_AUTOMATIC - - - - - - - - 2 - - - - - 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, + + + Untitled - SGPEMv2 Ford Prefect + 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 + _Simulation + True + + + + + + + True + gtk-media-play + True + + + + + + + + + + True + _Edit + True + + + + + + + True + gtk-preferences + True + + + + + + + + + + True + _Help + True + + + + + + + True + gtk-about + True + + + + + + + + + + True + _Debug + True + + + + + + + True + gtk-dialog-error + 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 + False + 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 + + + + + + True + True + + + + True + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_IN + + + + 3 + True + False + 0 + + + + True + True + True + 0 + + + + + + + + True + Schedulables + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + True + True + 0 + + + + + + + + True + Resources + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + True + False + 0 + + + + + + + + True + Requests + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + False + True + + + + + + + + + True + 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 + + + + + + + + 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. - Giovanni Giacobbi <ggiacobb@studenti.math.unipd.it> + False + 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> - - translator-credits - - - True - 12 - - - - - - True - GTK_BUTTONBOX_END - - - False - GTK_PACK_END - - - - - + + + + + + True + False + 12 + + + + + + + + True + GTK_BUTTONBOX_END + + + 0 + False + True + GTK_PACK_END + + + + + + diff --git a/src/backend/global_preferences.cc b/src/backend/global_preferences.cc index 21ce6ea..321df5f 100644 --- a/src/backend/global_preferences.cc +++ b/src/backend/global_preferences.cc @@ -32,7 +32,7 @@ using namespace sgpem; template class SG_DLLEXPORT Singleton; GlobalPreferences::GlobalPreferences() - : _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR) + : _mod_dirs(1, PLUGDIR), _pol_dirs(1, POLDIR), _speed(1000) {} diff --git a/src/graphical_preferences_editor.cc b/src/graphical_preferences_editor.cc new file mode 100644 index 0000000..376ad86 --- /dev/null +++ b/src/graphical_preferences_editor.cc @@ -0,0 +1,206 @@ +// src/graphical_preferences_editor.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 "graphical_preferences_editor.hh" + +#include +#include + + + + +using namespace sgpem; +using Gnome::Glade::Xml; + +PreferencesEditor::PreferencesEditor(const std::string& gladefile) + : _refXml(Xml::create(gladefile)), prefs(GlobalPreferences::get_instance()), + preferences_dialog(NULL), plugins_dirs_treeview(NULL), speed_spin(NULL) +{ + _refXml->get_widget("ConfigureDialog", preferences_dialog); + + // - General Dialog Settings + // preferences dialog + Gtk::Button* close = NULL; + _refXml->get_widget("Close", close); + close->signal_clicked().connect(sigc::mem_fun(*this, &PreferencesEditor::on_close)); + + + + // - Plugins + // - create model + Gtk::TreeModelColumnRecord model_columns; + Gtk::TreeModelColumn single_column; + model_columns.add(single_column); + + // here is our model + plugins_dirs_model = Gtk::ListStore::create(model_columns); + + _refXml->get_widget("Plugins.Additional.TreeView", plugins_dirs_treeview); + plugins_dirs_treeview->set_model(plugins_dirs_model); + plugins_dirs_treeview->append_column("path", single_column); + + // - fill model + typedef std::vector Strings; + Strings & plugin_dirs = prefs.get_plugin_dirs(); + for (Strings::const_iterator i_pd = plugin_dirs.begin(); i_pd != plugin_dirs.end(); i_pd++) + { + Gtk::TreeModel::iterator new_row = plugins_dirs_model->prepend(); // plugin dirs are sorted by backend in reverse order + new_row->set_value(0, *i_pd); + } + + Gtk::Button* add_plugins_dir = NULL; + _refXml->get_widget("Plugins.Add", add_plugins_dir); + add_plugins_dir->signal_clicked().connect(sigc::mem_fun(*this, &PreferencesEditor::on_add_plugins_dir)); + + Gtk::Button* remove_plugins_dir = NULL; + _refXml->get_widget("Plugins.Remove", remove_plugins_dir); + remove_plugins_dir->signal_clicked().connect(sigc::mem_fun(*this, &PreferencesEditor::on_remove_plugins_dir)); + + + + + + + + + + // - Policies + // - create model + Gtk::TreeModelColumnRecord model_columns2; + Gtk::TreeModelColumn single_column2; + model_columns2.add(single_column2); + + // here is our model + policies_dirs_model = Gtk::ListStore::create(model_columns2); + + _refXml->get_widget("Policies.Additional.TreeView", policies_dirs_treeview); + policies_dirs_treeview->set_model(policies_dirs_model); + policies_dirs_treeview->append_column("path", single_column2); + + // - fill model + typedef std::vector Strings; + Strings & policies_dirs = prefs.get_policy_dirs(); + for (Strings::const_iterator i_pd = policies_dirs.begin(); i_pd != policies_dirs.end(); i_pd++) + { + Gtk::TreeModel::iterator new_row = policies_dirs_model->prepend(); // plugin dirs are sorted by backend in reverse order + new_row->set_value(0, *i_pd); + } + + Gtk::Button* add_policies_dir = NULL; + _refXml->get_widget("Policies.Add", add_policies_dir); + add_policies_dir->signal_clicked().connect(sigc::mem_fun(*this, &PreferencesEditor::on_add_policies_dir)); + + Gtk::Button* remove_policies_dir = NULL; + _refXml->get_widget("Policies.Remove", remove_policies_dir); + remove_policies_dir->signal_clicked().connect(sigc::mem_fun(*this, &PreferencesEditor::on_remove_policies_dir)); + + + + // - Speed + + _refXml->get_widget("Speed.SpinButton", speed_spin); + speed_spin->set_value(prefs.get_speed()); + speed_spin->signal_value_changed().connect(sigc::mem_fun(*this, &PreferencesEditor::on_set_speed)); + + + + + // Window& main_window = get_initial_window(); + preferences_dialog->show(); +} + +void +PreferencesEditor::on_close() +{ + preferences_dialog->hide(); +} + +void +PreferencesEditor::on_add_plugins_dir() +{ + // I must get a string + Glib::ustring path; + Gtk::FileChooserDialog* ask_path = new Gtk::FileChooserDialog::FileChooserDialog( + _("Select a directory to add"), + Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path); + ask_path->add_button("gtk-cancel", Gtk::RESPONSE_CANCEL); + ask_path->add_button("gtk-ok", Gtk::RESPONSE_OK); + ask_path->show(); + int response = ask_path->run(); + ask_path->hide(); + if (response == Gtk::RESPONSE_OK) + { + path = ask_path->get_filename(); + prefs.add_modules_dir(path); + + Gtk::TreeModel::iterator new_row = plugins_dirs_model->append(); + new_row->set_value(0, path); + } +} + +void +PreferencesEditor::on_remove_plugins_dir() +{ + // Feature not supported by backend +} + +void +PreferencesEditor::on_add_policies_dir() +{ + // I must get a string + Glib::ustring path; + Gtk::FileChooserDialog* ask_path = new Gtk::FileChooserDialog::FileChooserDialog( + _("Select a directory to add"), + Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path); + ask_path->add_button("gtk-cancel", Gtk::RESPONSE_CANCEL); + ask_path->add_button("gtk-ok", Gtk::RESPONSE_OK); + ask_path->show(); + int response = ask_path->run(); + ask_path->hide(); + if (response == Gtk::RESPONSE_OK) + { + path = ask_path->get_filename(); + prefs.add_policies_dir(path); + + Gtk::TreeModel::iterator new_row = policies_dirs_model->append(); + new_row->set_value(0, path); + } +} + +void +PreferencesEditor::on_remove_policies_dir() +{ + // Feature not supported by backend +} + +void +PreferencesEditor::on_set_speed() +{ + prefs.set_speed(speed_spin->get_value()); +} + + +PreferencesEditor::~PreferencesEditor() +{ +} + diff --git a/src/graphical_preferences_editor.hh b/src/graphical_preferences_editor.hh new file mode 100644 index 0000000..0f20d65 --- /dev/null +++ b/src/graphical_preferences_editor.hh @@ -0,0 +1,83 @@ +// src/graphical_preferences_editor.hh - 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 + +#ifndef GRAPHICAL_PREFERENCES_EDITOR_HH +#define GRAPHICAL_PREFERENCES_EDITOR_HH 1 + + +#include "config.h" + +#include "backend/global_preferences.hh" + +#include +#include +#include +#include +#include + +#include + +namespace sgpem +{ + + class PreferencesEditor + { + + public: + + PreferencesEditor(const std::string& gladefile = GLADEDIR "/configure-dialog.glade"); + + + void + on_close(); + + void + on_add_plugins_dir(); + + void + on_remove_plugins_dir(); + + void + on_add_policies_dir(); + + void + on_remove_policies_dir(); + + void + on_set_speed(); + + + ~PreferencesEditor(); + + private: + Glib::RefPtr _refXml; + GlobalPreferences& prefs; + Gtk::Dialog* preferences_dialog; + Gtk::TreeView* plugins_dirs_treeview; + Glib::RefPtr plugins_dirs_model; + Gtk::TreeView* policies_dirs_treeview; + Glib::RefPtr policies_dirs_model; + Gtk::SpinButton* speed_spin; + + }; + +} + +#endif diff --git a/src/gui_builder.cc b/src/gui_builder.cc index ae8dd89..5d5aa34 100644 --- a/src/gui_builder.cc +++ b/src/gui_builder.cc @@ -25,6 +25,7 @@ #include "simulation_widget.hh" #include "gui_builder.hh" +#include "graphical_preferences_editor.hh" #include "backend/history.hh" #include "backend/simulation.hh" @@ -49,13 +50,19 @@ test_me() sim.get_history().add_process("goofy", 0, 0); } +void +GuiBuilder::on_edit_preferences_activate() +{ + new PreferencesEditor(); //FIXME: are we leaking this way? +} + GuiBuilder::GuiBuilder(const std::string& gladefile) : _refXml(Xml::create(gladefile)) { using namespace Gtk; - Window& main_window = get_initial_window(); + //Window& main_window = get_initial_window(); // Connect extra signals (decide where to do this... // here -- ugly -- derive widgets and then use @@ -64,13 +71,29 @@ GuiBuilder::GuiBuilder(const std::string& gladefile) _refXml->get_widget("MenuItem.File.Quit", file_quit); file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit)); + // preferences dialog + MenuItem* edit_preferences = NULL; + _refXml->get_widget("MenuItem.Edit.Preferences", edit_preferences); + edit_preferences->signal_activate().connect(sigc::mem_fun(*this, &GuiBuilder::on_edit_preferences_activate)); + + // 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)); + help_about->signal_activate().connect(sigc::mem_fun(*about_dialog, &Window::show)); + + + + + // Random Error Generator + MenuItem* debug_error = NULL; + _refXml->get_widget("MenuItem.Debug.Error", debug_error); + debug_error->signal_activate().connect(sigc::ptr_fun(test_me)); + + + // Temporary code to test the Schedulables custom widget Expander* scheds_expander = NULL; @@ -82,6 +105,8 @@ GuiBuilder::GuiBuilder(const std::string& gladefile) scheds_widget->show(); + + // Main simulation widget ScrolledWindow* simulation_window = NULL; _refXml->get_widget("SimulationScrolledWindow", simulation_window); diff --git a/src/gui_builder.hh b/src/gui_builder.hh index 60fba8b..0ec4e7d 100644 --- a/src/gui_builder.hh +++ b/src/gui_builder.hh @@ -42,6 +42,7 @@ namespace sgpem Gtk::Window& get_initial_window() const; void open_file(const std::string& filename); + void on_edit_preferences_activate(); private: Glib::RefPtr _refXml;