- 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
This commit is contained in:
elvez 2006-08-30 00:14:44 +00:00
parent cb59a30e06
commit 9d541e2751
2 changed files with 27 additions and 28 deletions

View File

@ -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<ActionGroup> 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> 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<Process>(it));
marked_up = markup_schedulable(*get_row_handle_as<Process>(it));
break;
case htype_thread:
marked_up = markup_schedulable(*get_row_handle_as<Thread>(it));
break;
default:
marked_up = "<small>";
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 << "<span foreground=\"" << schedulable_map_color(p.get_state()) << "\"><b>"
<< Markup::escape_text(p.get_name()) << "</b></span>"
<< _(", arrived at: ") << p.get_arrival_time()
<< _(", base priority: ") << p.get_base_priority() << endl
<< "<small>" << _("Elapsed time: ") << p.get_elapsed_time()
<< _(", current priority: ") << p.get_current_priority()
oss << "<small><span foreground=\"" << schedulable_map_color(s.get_state()) << "\"><b>"
<< Markup::escape_text(s.get_name()) << "</b></span>"
<< _(", arrived at: ") << s.get_arrival_time()
<< _(", base priority: ") << s.get_base_priority()
<< _(", elapsed time: ") << s.get_elapsed_time()
<< _(", current priority: ") << s.get_current_priority()
<< "</small>";
// TODO I'm unable to set foreground color, why?
return oss.str();
}

View File

@ -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<Gtk::TreeStore> _model;
Gtk::TreeModelColumnRecord _columns;