- All dialogs created by SchedulablesTreeWidget are now inializated only when needed

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@967 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-08-30 15:54:47 +00:00
parent a4bde96a7b
commit 685a6d84f0
3 changed files with 44 additions and 40 deletions

View File

@ -107,9 +107,9 @@ AddRequestDialog::run_add(Thread& owner)
Request* r = NULL;
// reset the dialog data
_list_model->clear();
_instant_spin->set_value(0.0);
_duration_spin->set_value(0.0);
// _list_model->clear();
// _instant_spin->set_value(0.0);
// _duration_spin->set_value(0.0);
if(run() == RESPONSE_OK)
{

View File

@ -52,10 +52,7 @@ SchedulablesTreeWidget::CellRendererTextMarkup::_property_renderable()
return Glib::PropertyProxy_Base(this, "markup");
}
SchedulablesTreeWidget::SchedulablesTreeWidget() :
_add_thread_dialog_glade(Xml::create(GLADEDIR "/add-thread-dialog.glade")),
_add_request_dialog_glade(Xml::create(GLADEDIR "/add-request-dialog.glade"))
SchedulablesTreeWidget::SchedulablesTreeWidget()
{
_columns.add(_main_column);
_columns.add(_types_column);
@ -68,12 +65,6 @@ SchedulablesTreeWidget::SchedulablesTreeWidget() :
Gtk::TreeViewColumn* tvc = get_column(idx);
tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_cell_name_data));
/** DIALOGS **/
_add_thread_dialog_glade->get_widget("AddThreadDialog", _add_thread_dialog);
// NOTE This is *not* reflective programming! AddRequestDialog is the name of
// the base widget in the glade file.
_add_request_dialog_glade->get_widget_derived("AddRequestDialog", _add_request_dialog);
set_headers_visible(false);
Simulation::get_instance().get_history().attach(*this);
@ -391,12 +382,12 @@ SchedulablesTreeWidget::add_edit_process(bool adding)
arrival_time_spin->set_value(static_cast<double>(selection->get_arrival_time()));
base_priority_spin->set_value(static_cast<double>(selection->get_base_priority()));
}
else
{
name_entry->set_text("");
arrival_time_spin->set_value(0.0);
base_priority_spin->set_value(0.0);
}
// else
// {
// name_entry->set_text("");
// arrival_time_spin->set_value(0.0);
// base_priority_spin->set_value(0.0);
// }
if(add_process_dialog->run() == RESPONSE_OK)
@ -437,16 +428,21 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
{
/** This is ugly, I know, we should be using derived widgets, but I also believe we
* have little time, and I'm not going to waste too much of it on the frontend */
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-thread-dialog.glade"));
Dialog* add_thread_dialog;
glade->get_widget("AddThreadDialog", add_thread_dialog);
Entry* name_entry;
SpinButton* cpu_time_spin;
SpinButton* arrival_time_spin;
SpinButton* base_priority_spin;
_add_thread_dialog_glade->get_widget("Name.Entry", name_entry);
_add_thread_dialog_glade->get_widget("CpuTime.Spin", cpu_time_spin);
_add_thread_dialog_glade->get_widget("ArrivalTime.Spin", arrival_time_spin);
_add_thread_dialog_glade->get_widget("BasePriority.Spin", base_priority_spin);
glade->get_widget("Name.Entry", name_entry);
glade->get_widget("CpuTime.Spin", cpu_time_spin);
glade->get_widget("ArrivalTime.Spin", arrival_time_spin);
glade->get_widget("BasePriority.Spin", base_priority_spin);
Thread* t = NULL;
@ -459,16 +455,16 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
arrival_time_spin->set_value(static_cast<double>(t->get_arrival_time()));
base_priority_spin->set_value(static_cast<double>(t->get_base_priority()));
}
else
{
name_entry->set_text("");
cpu_time_spin->set_value(1.0);
arrival_time_spin->set_value(0.0);
base_priority_spin->set_value(0.0);
}
// else
// {
// name_entry->set_text("");
// cpu_time_spin->set_value(1.0);
// arrival_time_spin->set_value(0.0);
// base_priority_spin->set_value(0.0);
// }
if(_add_thread_dialog->run() == RESPONSE_OK)
if(add_thread_dialog->run() == RESPONSE_OK)
{
if(adding)
@ -494,27 +490,39 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
}
_add_thread_dialog->hide();
add_thread_dialog->hide();
}
void
SchedulablesTreeWidget::_on_add_request()
{
Thread* t = get_selected<Thread>();
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-request-dialog.glade"));
AddRequestDialog* add_request_dialog;
// NOTE This is *not* reflective programming! AddRequestDialog is the name of
// the base widget in the glade file.
glade->get_widget("AddRequestDialog", add_request_dialog);
Thread* t = get_selected<Thread>();
assert(t != NULL);
_add_request_dialog->run_add(*t);
add_request_dialog->run_add(*t);
}
void
SchedulablesTreeWidget::_on_edit_request()
{
Request* r = get_selected<Request>();
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-request-dialog.glade"));
AddRequestDialog* add_request_dialog;
// NOTE This is *not* reflective programming! AddRequestDialog is the name of
// the base widget in the glade file.
glade->get_widget("AddRequestDialog", add_request_dialog);
Request* r = get_selected<Request>();
assert(r != NULL);
_add_request_dialog->run_edit(*r);
add_request_dialog->run_edit(*r);
}
void

View File

@ -114,10 +114,6 @@ namespace sgpem
Gtk::TreeModelColumn<HandleType> _types_column;
Gtk::TreeModelColumn<void*> _handles_column;
Glib::RefPtr<Gtk::UIManager> _UIManager;
Glib::RefPtr<Gnome::Glade::Xml> _add_thread_dialog_glade;
Glib::RefPtr<Gnome::Glade::Xml> _add_request_dialog_glade;
Gtk::Dialog* _add_thread_dialog;
AddRequestDialog* _add_request_dialog;
CellRendererTextMarkup _cell_renderer;
void _update_expanded_vector(Gtk::TreeView* tree_view, const Gtk::TreeModel::Path& path);