Fix CPUFrequency replicant localization to no longer crash. Sorry about that :)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33408 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2009-10-02 15:31:41 +00:00
parent 9e0985f930
commit b0ca26e475
3 changed files with 19 additions and 11 deletions

View File

@ -31,7 +31,7 @@ const bigtime_t kMilliSecond = 1000;
CPUFrequencyView::CPUFrequencyView(BRect frame, CPUFrequencyView::CPUFrequencyView(BRect frame,
PreferencesStorage<freq_preferences>* storage) PreferencesStorage<freq_preferences>* storage)
: BView(frame, "CPUFrequencyView", B_FOLLOW_NONE, B_WILL_DRAW), : BView(frame, "CPUFrequencyView", B_FOLLOW_NONE, B_WILL_DRAW),
fStorage(storage) fStorage(storage)
{ {
@ -155,7 +155,7 @@ void
CPUFrequencyView::AttachedToWindow() CPUFrequencyView::AttachedToWindow()
{ {
fFrequencyMenu = new FrequencyMenu(fPolicyMenu, this, fFrequencyMenu = new FrequencyMenu(fPolicyMenu, this,
fStorage, &fDriverInterface); fStorage, &fDriverInterface);
AddFilter(fFrequencyMenu); AddFilter(fFrequencyMenu);
fColorStepView->SetTarget(this); fColorStepView->SetTarget(this);

View File

@ -194,18 +194,21 @@ FrequencyMenu::FrequencyMenu(BMenu* menu, BHandler* target,
fStorage(storage), fStorage(storage),
fInterface(interface) fInterface(interface)
{ {
fDynamicPerformance = new BMenuItem(TR("Dynamic Performance"), BCatalog cat("x-vnd.Haiku-CPUFrequencyPref");
fDynamicPerformance = new BMenuItem(
cat.GetString("Dynamic Performance",TR_CONTEXT),
new BMessage(kMsgPolicyDynamic)); new BMessage(kMsgPolicyDynamic));
fHighPerformance = new BMenuItem(TR("High Performance"), fHighPerformance = new BMenuItem(
cat.GetString("High Performance",TR_CONTEXT),
new BMessage(kMsgPolicyPerformance)); new BMessage(kMsgPolicyPerformance));
fLowEnergie = new BMenuItem(TR("Low Energy"), fLowEnergie = new BMenuItem(cat.GetString("Low Energy",TR_CONTEXT),
new BMessage(kMsgPolicyLowEnergy)); new BMessage(kMsgPolicyLowEnergy));
menu->AddItem(fDynamicPerformance); menu->AddItem(fDynamicPerformance);
menu->AddItem(fHighPerformance); menu->AddItem(fHighPerformance);
menu->AddItem(fLowEnergie); menu->AddItem(fLowEnergie);
fCustomStateMenu = new BMenu(TR("Set State")); fCustomStateMenu = new BMenu(cat.GetString("Set State",TR_CONTEXT));
StateList* stateList = fInterface->GetCpuFrequencyStates(); StateList* stateList = fInterface->GetCpuFrequencyStates();
for (int i = 0; i < stateList->CountItems(); i++) { for (int i = 0; i < stateList->CountItems(); i++) {
@ -348,7 +351,8 @@ StatusView::StatusView(BRect frame, bool inDeskbar,
B_WILL_DRAW | B_FRAME_EVENTS), B_WILL_DRAW | B_FRAME_EVENTS),
fInDeskbar(inDeskbar), fInDeskbar(inDeskbar),
fCurrentFrequency(NULL), fCurrentFrequency(NULL),
fDragger(NULL) fDragger(NULL),
cat("x-vnd.Haiku-CPUFrequencyPref")
{ {
if (!inDeskbar) { if (!inDeskbar) {
// we were obviously added to a standard window - let's add a dragger // we were obviously added to a standard window - let's add a dragger
@ -401,9 +405,9 @@ StatusView::~StatusView()
void void
StatusView::_AboutRequested() StatusView::_AboutRequested()
{ {
BAlert *alert = new BAlert("about", TR("CPU Frequency\n" BAlert *alert = new BAlert("about", cat.GetString("CPU Frequency\n"
"\twritten by Clemens Zeidler\n" "\twritten by Clemens Zeidler\n"
"\tCopyright 2009, Haiku, Inc.\n"), TR("Ok")); "\tCopyright 2009, Haiku, Inc.\n",TR_CONTEXT), cat.GetString("Ok",TR_CONTEXT));
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
BFont font; BFont font;
@ -483,13 +487,15 @@ StatusView::AttachedToWindow()
fPreferencesMenu->SetFont(be_plain_font); fPreferencesMenu->SetFont(be_plain_font);
fPreferencesMenu->AddSeparatorItem(); fPreferencesMenu->AddSeparatorItem();
fOpenPrefItem = new BMenuItem(TR("Open Speedstep Preferences" B_UTF8_ELLIPSIS), fOpenPrefItem = new BMenuItem(
cat.GetString("Open Speedstep Preferences" B_UTF8_ELLIPSIS, TR_CONTEXT),
new BMessage(kMsgOpenSSPreferences)); new BMessage(kMsgOpenSSPreferences));
fPreferencesMenu->AddItem(fOpenPrefItem); fPreferencesMenu->AddItem(fOpenPrefItem);
fOpenPrefItem->SetTarget(this); fOpenPrefItem->SetTarget(this);
if (fInDeskbar) { if (fInDeskbar) {
fQuitItem= new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)); fQuitItem= new BMenuItem(cat.GetString("Quit", TR_CONTEXT),
new BMessage(B_QUIT_REQUESTED));
fPreferencesMenu->AddItem(fQuitItem); fPreferencesMenu->AddItem(fQuitItem);
fQuitItem->SetTarget(this); fQuitItem->SetTarget(this);
} }

View File

@ -135,6 +135,8 @@ class StatusView : public BView {
BString fFreqString; BString fFreqString;
BDragger* fDragger; BDragger* fDragger;
BCatalog cat;
}; };
#endif // STATUS_VIEW_H #endif // STATUS_VIEW_H