From 9d541e2751f446bf7da894e0018c563778e00b14 Mon Sep 17 00:00:00 2001 From: elvez Date: Wed, 30 Aug 2006 00:14:44 +0000 Subject: [PATCH] - Added markup for threads, improved support for translation of hard-coded strings git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@963 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/schedulables_tree_widget.cc | 52 ++++++++++++++++----------------- src/schedulables_tree_widget.hh | 3 +- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/schedulables_tree_widget.cc b/src/schedulables_tree_widget.cc index 22afcd2..f11a718 100644 --- a/src/schedulables_tree_widget.cc +++ b/src/schedulables_tree_widget.cc @@ -65,11 +65,7 @@ SchedulablesTreeWidget::SchedulablesTreeWidget() : set_model(_model); - //append_column("schedulables", _main_column); - //invisible - // append_column("handles", _types_column); - // append_column("handles", _handles_column); - int idx = append_column("schedulables", _cell_renderer) - 1; + int idx = append_column(_("schedulables"), _cell_renderer) - 1; Gtk::TreeViewColumn* tvc = get_column(idx); tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_cell_name_data)); @@ -180,34 +176,34 @@ SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event) { RefPtr action_group = Gtk::ActionGroup::create(); - action_group->add( Gtk::Action::create("AddProcess", "Add Process"), + action_group->add( Gtk::Action::create("AddProcess", _("Add Process")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) ); - action_group->add( Gtk::Action::create("AddThread", "Add Thread"), + action_group->add( Gtk::Action::create("AddThread", _("Add Thread")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_thread) ); - action_group->add( Gtk::Action::create("AddRequest", "Add Request"), + action_group->add( Gtk::Action::create("AddRequest", _("Add Request")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_request) ); - action_group->add( Gtk::Action::create("EditProcess", "Edit Process"), + action_group->add( Gtk::Action::create("EditProcess", _("Edit Process")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_process) ); - action_group->add( Gtk::Action::create("EditThread", "Edit Thread"), + action_group->add( Gtk::Action::create("EditThread", _("Edit Thread")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_thread) ); - action_group->add( Gtk::Action::create("EditRequest", "Edit Request"), + action_group->add( Gtk::Action::create("EditRequest", _("Edit Request")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_edit_request) ); - action_group->add( Gtk::Action::create("RemoveProcess", "Remove Process"), + action_group->add( Gtk::Action::create("RemoveProcess", _("Remove Process")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_process) ); - action_group->add( Gtk::Action::create("RemoveThread", "Remove Thread"), + action_group->add( Gtk::Action::create("RemoveThread", _("Remove Thread")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_thread) ); - action_group->add( Gtk::Action::create("RemoveRequest", "Remove Request"), + action_group->add( Gtk::Action::create("RemoveRequest", _("Remove Request")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_request) ); - action_group->add( Gtk::Action::create("RemoveSubrequest", "Remove Subrequest"), + action_group->add( Gtk::Action::create("RemoveSubrequest", _("Remove Subrequest")), sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_remove_subrequest) ); RefPtr UIManager = Gtk::UIManager::create(); @@ -274,7 +270,6 @@ SchedulablesTreeWidget::_update_expanded_vector(Gtk::TreeView*, const Gtk::TreeM _expanded_rows.push_back(path.to_string()); } - void SchedulablesTreeWidget::update(const History& history) { @@ -323,7 +318,7 @@ SchedulablesTreeWidget::update(const History& history) TreeModel::Row rrow = *(_model->append(trow.children())); std::ostringstream oss; - oss << "request " << ri + 1; + oss << _("request ") << ri + 1; rrow[_main_column] = oss.str(); rrow[_types_column] = htype_request; @@ -572,8 +567,13 @@ SchedulablesTreeWidget::_on_cell_name_data(Gtk::CellRenderer* cr, switch(get_row_type(it)) { case htype_process: - marked_up = markup_process(*get_row_handle_as(it)); + marked_up = markup_schedulable(*get_row_handle_as(it)); break; + + case htype_thread: + marked_up = markup_schedulable(*get_row_handle_as(it)); + break; + default: marked_up = ""; marked_up += Markup::escape_text(it->get_value(_main_column)); @@ -583,7 +583,6 @@ SchedulablesTreeWidget::_on_cell_name_data(Gtk::CellRenderer* cr, crtm.property_markup() = marked_up; } - static Glib::ustring schedulable_map_color(const Schedulable::state st) { @@ -606,7 +605,7 @@ schedulable_map_color(const Schedulable::state st) ustring -SchedulablesTreeWidget::markup_process(const Process& p) +SchedulablesTreeWidget::markup_schedulable(const Schedulable& s) { using std::ostringstream; using std::endl; @@ -615,15 +614,14 @@ SchedulablesTreeWidget::markup_process(const Process& p) // TODO : add note for the translator to use HTML-escaped text // See the gettext manual. - oss << "" - << Markup::escape_text(p.get_name()) << "" - << _(", arrived at: ") << p.get_arrival_time() - << _(", base priority: ") << p.get_base_priority() << endl - << "" << _("Elapsed time: ") << p.get_elapsed_time() - << _(", current priority: ") << p.get_current_priority() + oss << "" + << Markup::escape_text(s.get_name()) << "" + << _(", arrived at: ") << s.get_arrival_time() + << _(", base priority: ") << s.get_base_priority() + << _(", elapsed time: ") << s.get_elapsed_time() + << _(", current priority: ") << s.get_current_priority() << ""; - // TODO I'm unable to set foreground color, why? return oss.str(); } diff --git a/src/schedulables_tree_widget.hh b/src/schedulables_tree_widget.hh index 05b2aa8..5804552 100644 --- a/src/schedulables_tree_widget.hh +++ b/src/schedulables_tree_widget.hh @@ -23,6 +23,7 @@ namespace sgpem { + class Schedulable; class Process; class Thread; class AddRequestDialog; @@ -105,7 +106,7 @@ namespace sgpem void _on_cell_name_data(Gtk::CellRenderer* cr, const Gtk::TreeModel::iterator& it); - Glib::ustring markup_process(const Process& p); + Glib::ustring markup_schedulable(const Schedulable& s); Glib::RefPtr _model; Gtk::TreeModelColumnRecord _columns;