- Add policy description to configure_policy_dialog

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@980 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-01 12:08:26 +00:00
parent 0912042b50
commit 17b54f1bfe
3 changed files with 31 additions and 12 deletions

View File

@ -43,9 +43,11 @@ using namespace Gtk;
// of the table. If you change it, you've to edit all the other methods // of the table. If you change it, you've to edit all the other methods
// to reflect it, expecially "on_okay()" // to reflect it, expecially "on_okay()"
ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring title, ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring& title,
Gtk::Window& parent,
const Glib::ustring& description,
PolicyParameters& parameters) PolicyParameters& parameters)
: Gtk::Dialog(title, true, true), _parameters(parameters), : Gtk::Dialog(title, parent, true, true), _parameters(parameters),
_table_int(NULL), _table_float(NULL), _table_string(NULL) _table_int(NULL), _table_float(NULL), _table_string(NULL)
{ {
typedef std::map<Glib::ustring, PolicyParameters::Parameter<int> > IntParams; typedef std::map<Glib::ustring, PolicyParameters::Parameter<int> > IntParams;
@ -55,13 +57,22 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring title,
VBox& main_vbox = *get_vbox(); VBox& main_vbox = *get_vbox();
guint row_n; guint row_n;
// Insert policy description
Frame& descr_frame = *manage(create_category(_("Policy description")));
main_vbox.pack_start(descr_frame);
Label& descr_label = *manage(new Label(description));
descr_label.set_line_wrap(true);
descr_label.set_justify(JUSTIFY_FILL);
descr_label.set_padding(5, 5);
descr_frame.add(descr_label);
// Integer parameters // Integer parameters
const IntParams intpars = _parameters.get_registered_int_parameters(); const IntParams intpars = _parameters.get_registered_int_parameters();
if(!intpars.empty()) if(!intpars.empty())
{ {
Frame& intframe = *manage(create_category(_("Integer values"))); Frame& intframe = *manage(create_category(_("Integer values")));
main_vbox.pack_end(intframe); main_vbox.pack_start(intframe);
_table_int = manage(new Table(intpars.size(), 2)); _table_int = manage(new Table(intpars.size(), 2));
_table_int->set_row_spacings(2); _table_int->set_row_spacings(2);
_table_int->set_col_spacings(2); _table_int->set_col_spacings(2);
@ -79,7 +90,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring title,
if(!floatpars.empty()) if(!floatpars.empty())
{ {
Frame& floatframe = *manage(create_category(_("Floating point values"))); Frame& floatframe = *manage(create_category(_("Floating point values")));
main_vbox.pack_end(floatframe); main_vbox.pack_start(floatframe);
_table_float = manage(new Table(floatpars.size(), 2)); _table_float = manage(new Table(floatpars.size(), 2));
_table_float->set_row_spacings(2); _table_float->set_row_spacings(2);
_table_float->set_col_spacings(2); _table_float->set_col_spacings(2);
@ -96,7 +107,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring title,
if(!stringpars.empty()) if(!stringpars.empty())
{ {
Frame& stringframe = *manage(create_category(_("Alphanumerical values"))); Frame& stringframe = *manage(create_category(_("Alphanumerical values")));
main_vbox.pack_end(stringframe); main_vbox.pack_start(stringframe);
_table_string = manage(new Table(stringpars.size(), 2)); _table_string = manage(new Table(stringpars.size(), 2));
_table_string->set_row_spacings(2); _table_string->set_row_spacings(2);
_table_string->set_col_spacings(2); _table_string->set_col_spacings(2);
@ -111,6 +122,7 @@ ConfigurePolicyDialog::ConfigurePolicyDialog(const Glib::ustring title,
if(_table_int == NULL && _table_float == NULL && _table_string == NULL) if(_table_int == NULL && _table_float == NULL && _table_string == NULL)
{ {
Label& message = *manage(new Label(_("No options to configure for this policy"))); Label& message = *manage(new Label(_("No options to configure for this policy")));
message.set_padding(5, 5);
main_vbox.pack_end(message); main_vbox.pack_end(message);
} }

View File

@ -36,7 +36,10 @@ namespace sgpem
class ConfigurePolicyDialog : public Gtk::Dialog class ConfigurePolicyDialog : public Gtk::Dialog
{ {
public: public:
ConfigurePolicyDialog(const Glib::ustring title, PolicyParameters& parameters); ConfigurePolicyDialog(const Glib::ustring& title,
Gtk::Window& parent,
const Glib::ustring& description,
PolicyParameters& parameters);
protected: protected:
Gtk::Frame* create_category(const Glib::ustring& type_name) const; Gtk::Frame* create_category(const Glib::ustring& type_name) const;

View File

@ -209,14 +209,16 @@ GuiBuilder::on_configure_cpu_policy()
if(policy == NULL) if(policy == NULL)
{ {
MessageDialog warn(_("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."), MessageDialog warn(get_initial_window(),
_("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."),
true, MESSAGE_WARNING, BUTTONS_OK, true); true, MESSAGE_WARNING, BUTTONS_OK, true);
warn.run(); warn.run();
return; return;
} }
PolicyParameters& params = policy->get_parameters(); PolicyParameters& params = policy->get_parameters();
ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(), params); ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(),
get_initial_window(), policy->get_description(), params);
config_dialog.run(); config_dialog.run();
} }
@ -230,14 +232,16 @@ GuiBuilder::on_configure_resource_policy()
if(policy == NULL) if(policy == NULL)
{ {
MessageDialog warn(_("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."), MessageDialog warn(get_initial_window(),
_("<b>No CPU policy is currently selected.</b>\nPlease choose one before trying to configure it."),
true, MESSAGE_WARNING, BUTTONS_OK, true); true, MESSAGE_WARNING, BUTTONS_OK, true);
warn.run(); warn.run();
return; return;
} }
PolicyParameters& params = policy->get_parameters(); PolicyParameters& params = policy->get_parameters();
ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(), params); ConfigurePolicyDialog config_dialog(_("Configuring CPU Policy ") + policy->get_name(),
get_initial_window(), policy->get_description(), params);
config_dialog.run(); config_dialog.run();
} }