Patch by Karvjorm to localize the Pulse demo application. This closes ticket #6110.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37026 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Wim van der Meer
2010-06-06 06:25:13 +00:00
parent 1ba89e67ed
commit 42f6e06f3b
11 changed files with 193 additions and 88 deletions
+16 -9
View File
@@ -1,4 +1,4 @@
//**************************************************************************************** //*****************************************************************************
// //
// File: CPUButton.cpp // File: CPUButton.cpp
// //
@@ -6,8 +6,7 @@
// //
// Copyright 1999, Be Incorporated // Copyright 1999, Be Incorporated
// //
//**************************************************************************************** //*****************************************************************************
#include "CPUButton.h" #include "CPUButton.h"
@@ -15,7 +14,9 @@
#include <string.h> #include <string.h>
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <Dragger.h> #include <Dragger.h>
#include <Locale.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <ViewPrivate.h> #include <ViewPrivate.h>
@@ -26,6 +27,9 @@
#include "PulseView.h" #include "PulseView.h"
#include "Common.h" #include "Common.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "CPUButton"
CPUButton::CPUButton(BRect rect, const char *name, const char *label, BMessage *message) CPUButton::CPUButton(BRect rect, const char *name, const char *label, BMessage *message)
: BControl(rect, name, label, message, B_FOLLOW_NONE, B_WILL_DRAW) : BControl(rect, name, label, message, B_FOLLOW_NONE, B_WILL_DRAW)
@@ -195,11 +199,11 @@ CPUButton::MouseDown(BPoint point)
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
} else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0 } else if ((B_SECONDARY_MOUSE_BUTTON & mouseButtons) != 0
&& fReplicantInDeskbar) { && fReplicantInDeskbar) {
BPopUpMenu *menu = new BPopUpMenu("Deskbar menu"); BPopUpMenu *menu = new BPopUpMenu(B_TRANSLATE("Deskbar menu"));
menu->AddItem(new BMenuItem("About Pulse" B_UTF8_ELLIPSIS, menu->AddItem(new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Remove replicant", menu->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"),
new BMessage(kDeleteReplicant))); new BMessage(kDeleteReplicant)));
menu->SetTargetForItems(this); menu->SetTargetForItems(this);
@@ -237,7 +241,8 @@ CPUButton::Invoke(BMessage *message)
if (!LastEnabledCPU(fCPU)) { if (!LastEnabledCPU(fCPU)) {
_kern_set_cpu_enabled(fCPU, Value()); _kern_set_cpu_enabled(fCPU, Value());
} else { } else {
BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); BAlert *alert = new BAlert(NULL, B_TRANSLATE("You can't disable the "
"last active CPU."), B_TRANSLATE("OK"));
alert->Go(NULL); alert->Go(NULL);
SetValue(!Value()); SetValue(!Value());
} }
@@ -271,7 +276,9 @@ CPUButton::MessageReceived(BMessage *message)
{ {
switch (message->what) { switch (message->what) {
case B_ABOUT_REQUESTED: { case B_ABOUT_REQUESTED: {
BAlert *alert = new BAlert("Info", "Pulse\n\nBy David Ramsey and Arve Hjønnevåg\nRevised by Daniel Switkin", "OK"); BAlert *alert = new BAlert(B_TRANSLATE("Info"),
B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve Hjønnevåg\n"
"Revised by Daniel Switkin"), B_TRANSLATE("OK"));
// Use the asynchronous version so we don't block the window's thread // Use the asynchronous version so we don't block the window's thread
alert->Go(NULL); alert->Go(NULL);
break; break;
@@ -313,7 +320,7 @@ CPUButton::AttachedToWindow()
fReplicantInDeskbar = false; fReplicantInDeskbar = false;
if (fReplicant) { if (fReplicant) {
if (strcmp(Window()->Title(), "Deskbar")) { if (strcmp(Window()->Title(), B_TRANSLATE("Deskbar")) == 0) {
// Make room for dragger // Make room for dragger
ResizeBy(4, 4); ResizeBy(4, 4);
+22 -16
View File
@@ -14,7 +14,9 @@
#include "PulseApp.h" #include "PulseApp.h"
#include "PrefsWindow.h" #include "PrefsWindow.h"
#include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <Locale.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <TextControl.h> #include <TextControl.h>
@@ -23,6 +25,9 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
RTColorControl::RTColorControl(BPoint point, BMessage *message) RTColorControl::RTColorControl(BPoint point, BMessage *message)
: BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false) : BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false)
@@ -61,7 +66,7 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
fActiveButton = fIdleButton = fFrameButton = NULL; fActiveButton = fIdleButton = fFrameButton = NULL;
fIconWidthControl = NULL; fIconWidthControl = NULL;
SetLabel("Bar colors"); SetLabel(B_TRANSLATE("Bar colors"));
font_height fontHeight; font_height fontHeight;
be_bold_font->GetHeight(&fontHeight); be_bold_font->GetHeight(&fontHeight);
@@ -78,8 +83,8 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
if (mode == PRV_NORMAL_CHANGE_COLOR) { if (mode == PRV_NORMAL_CHANGE_COLOR) {
// normal mode // normal mode
fFadeCheckBox = new BCheckBox(rect, "FadeColors", "Fade colors", fFadeCheckBox = new BCheckBox(rect, "FadeColors",
new BMessage(PRV_NORMAL_FADE_COLORS)); B_TRANSLATE("Fade colors"), new BMessage(PRV_NORMAL_FADE_COLORS));
fFadeCheckBox->ResizeToPreferred(); fFadeCheckBox->ResizeToPreferred();
AddChild(fFadeCheckBox); AddChild(fFadeCheckBox);
@@ -88,42 +93,42 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
} else if (mode == PRV_MINI_CHANGE_COLOR) { } else if (mode == PRV_MINI_CHANGE_COLOR) {
// mini mode // mini mode
fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color", fActiveButton = new BRadioButton(rect, "ActiveColor",
new BMessage(PRV_MINI_ACTIVE)); B_TRANSLATE("Active color"), new BMessage(PRV_MINI_ACTIVE));
fActiveButton->ResizeToPreferred(); fActiveButton->ResizeToPreferred();
fActiveButton->SetValue(B_CONTROL_ON); fActiveButton->SetValue(B_CONTROL_ON);
AddChild(fActiveButton); AddChild(fActiveButton);
rect.left = fActiveButton->Frame().right + 5.0f; rect.left = fActiveButton->Frame().right + 5.0f;
fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color", fIdleButton = new BRadioButton(rect, "IdleColor",
new BMessage(PRV_MINI_IDLE)); B_TRANSLATE("Idle color"), new BMessage(PRV_MINI_IDLE));
fIdleButton->ResizeToPreferred(); fIdleButton->ResizeToPreferred();
AddChild(fIdleButton); AddChild(fIdleButton);
rect.left = fIdleButton->Frame().right + 5.0f; rect.left = fIdleButton->Frame().right + 5.0f;
fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color", fFrameButton = new BRadioButton(rect, "FrameColor",
new BMessage(PRV_MINI_FRAME)); B_TRANSLATE("Frame color"), new BMessage(PRV_MINI_FRAME));
fFrameButton->ResizeToPreferred(); fFrameButton->ResizeToPreferred();
AddChild(fFrameButton); AddChild(fFrameButton);
fColorControl->SetValue(fPrefs->mini_active_color); fColorControl->SetValue(fPrefs->mini_active_color);
} else { } else {
// deskbar mode // deskbar mode
fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color", fActiveButton = new BRadioButton(rect, "ActiveColor",
new BMessage(PRV_DESKBAR_ACTIVE)); B_TRANSLATE("Active color"), new BMessage(PRV_DESKBAR_ACTIVE));
fActiveButton->ResizeToPreferred(); fActiveButton->ResizeToPreferred();
fActiveButton->SetValue(B_CONTROL_ON); fActiveButton->SetValue(B_CONTROL_ON);
AddChild(fActiveButton); AddChild(fActiveButton);
rect.left = fActiveButton->Frame().right + 5.0f; rect.left = fActiveButton->Frame().right + 5.0f;
fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color", fIdleButton = new BRadioButton(rect, "IdleColor",
new BMessage(PRV_DESKBAR_IDLE)); B_TRANSLATE("Idle color"), new BMessage(PRV_DESKBAR_IDLE));
fIdleButton->ResizeToPreferred(); fIdleButton->ResizeToPreferred();
AddChild(fIdleButton); AddChild(fIdleButton);
rect.left = fIdleButton->Frame().right + 5.0f; rect.left = fIdleButton->Frame().right + 5.0f;
fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color", fFrameButton = new BRadioButton(rect, "FrameColor",
new BMessage(PRV_DESKBAR_FRAME)); B_TRANSLATE("Frame color"), new BMessage(PRV_DESKBAR_FRAME));
fFrameButton->ResizeToPreferred(); fFrameButton->ResizeToPreferred();
AddChild(fFrameButton); AddChild(fFrameButton);
@@ -132,7 +137,8 @@ ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& ta
char temp[10]; char temp[10];
snprintf(temp, sizeof(temp), "%d", fPrefs->deskbar_icon_width); snprintf(temp, sizeof(temp), "%d", fPrefs->deskbar_icon_width);
fIconWidthControl = new BTextControl(rect, "Width", "Width of icon:", temp, fIconWidthControl = new BTextControl(rect, "Width",
B_TRANSLATE("Width of icon:"), temp,
new BMessage(PRV_DESKBAR_ICON_WIDTH)); new BMessage(PRV_DESKBAR_ICON_WIDTH));
AddChild(fIconWidthControl); AddChild(fIconWidthControl);
fIconWidthControl->SetDivider(be_plain_font->StringWidth( fIconWidthControl->SetDivider(be_plain_font->StringWidth(
+15 -7
View File
@@ -12,13 +12,19 @@
#include "Common.h" #include "Common.h"
#include "Prefs.h" #include "Prefs.h"
#include <app/Application.h> #include <app/Application.h>
#include <Catalog.h>
#include <interface/Deskbar.h> #include <interface/Deskbar.h>
#include <interface/Alert.h> #include <interface/Alert.h>
#include <Locale.h>
#include <Roster.h> #include <Roster.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "DeskbarPulseView"
DeskbarPulseView::DeskbarPulseView(BRect rect) : MiniPulseView(rect, "DeskbarPulseView") { DeskbarPulseView::DeskbarPulseView(BRect rect) : MiniPulseView(rect, "DeskbarPulseView") {
messagerunner = NULL; messagerunner = NULL;
prefs = NULL; prefs = NULL;
@@ -26,11 +32,11 @@ DeskbarPulseView::DeskbarPulseView(BRect rect) : MiniPulseView(rect, "DeskbarPul
} }
DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) { DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) {
mode1->SetLabel("Normal mode"); mode1->SetLabel(B_TRANSLATE("Normal mode"));
mode1->SetMessage(new BMessage(PV_NORMAL_MODE)); mode1->SetMessage(new BMessage(PV_NORMAL_MODE));
mode2->SetLabel("Mini mode"); mode2->SetLabel(B_TRANSLATE("Mini mode"));
mode2->SetMessage(new BMessage(PV_MINI_MODE)); mode2->SetMessage(new BMessage(PV_MINI_MODE));
quit = new BMenuItem("Quit", new BMessage(PV_QUIT), 0, 0); quit = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(PV_QUIT), 0, 0);
popupmenu->AddSeparatorItem(); popupmenu->AddSeparatorItem();
popupmenu->AddItem(quit); popupmenu->AddItem(quit);
@@ -118,8 +124,9 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
prefswindow->Show(); prefswindow->Show();
break; break;
case PV_ABOUT: { case PV_ABOUT: {
BAlert *alert = new BAlert("Info", "Pulse\n\nBy David Ramsey and " BAlert *alert = new BAlert(B_TRANSLATE("Info"),
"Arve Hjønnevåg\nRevised by Daniel Switkin", "OK"); B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve Hjønnevåg\n"
"Revised by Daniel Switkin"), B_TRANSLATE("OK"));
alert->Go(NULL); alert->Go(NULL);
break; break;
} }
@@ -169,8 +176,9 @@ void DeskbarPulseView::Remove() {
status_t err = deskbar->RemoveItem("DeskbarPulseView"); status_t err = deskbar->RemoveItem("DeskbarPulseView");
if (err != B_OK) { if (err != B_OK) {
char temp[255]; char temp[255];
sprintf(temp, "Remove(): %s", strerror(err)); sprintf(temp, B_TRANSLATE("Remove(): %s"), strerror(err));
BAlert *alert = new BAlert("Info", temp, "OK"); BAlert *alert = new BAlert(B_TRANSLATE("Info"), temp,
B_TRANSLATE("OK"));
alert->Go(NULL); alert->Go(NULL);
} }
delete deskbar; delete deskbar;
+15 -1
View File
@@ -23,6 +23,20 @@ Application Pulse :
PulseView.cpp PulseView.cpp
PulseWindow.cpp PulseWindow.cpp
: be $(TARGET_LIBSUPC++) : be locale $(TARGET_LIBSUPC++)
: Pulse.rdef : Pulse.rdef
; ;
DoCatalogs Pulse :
x-vnd.Haiku-Pulse
:
PulseApp.cpp
PulseView.cpp
ConfigView.cpp
CPUButton.cpp
DeskbarPulseView.cpp
MiniPulseView.cpp
NormalPulseView.cpp
PrefsWindow.cpp
PulseWindow.cpp
;
+27 -11
View File
@@ -1,4 +1,4 @@
//**************************************************************************************** //*****************************************************************************
// //
// File: MiniPulseView.cpp // File: MiniPulseView.cpp
// //
@@ -6,20 +6,26 @@
// //
// Copyright 1999, Be Incorporated // Copyright 1999, Be Incorporated
// //
//**************************************************************************************** //*****************************************************************************
#include "MiniPulseView.h" #include "MiniPulseView.h"
#include "Common.h" #include "Common.h"
#include <Catalog.h>
#include <Locale.h>
#include <interface/Window.h> #include <interface/Window.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "MiniPulseView"
MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) : MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) :
PulseView(rect, name) { PulseView(rect, name) {
mode1->SetLabel("Normal mode"); mode1->SetLabel(B_TRANSLATE("Normal mode"));
mode1->SetMessage(new BMessage(PV_NORMAL_MODE)); mode1->SetMessage(new BMessage(PV_NORMAL_MODE));
mode2->SetLabel("Deskbar mode"); mode2->SetLabel(B_TRANSLATE("Deskbar mode"));
mode2->SetMessage(new BMessage(PV_DESKBAR_MODE)); mode2->SetMessage(new BMessage(PV_DESKBAR_MODE));
quit = new BMenuItem("Quit", new BMessage(PV_QUIT), 0, 0); quit = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(PV_QUIT), 0, 0);
popupmenu->AddSeparatorItem(); popupmenu->AddSeparatorItem();
popupmenu->AddItem(quit); popupmenu->AddItem(quit);
@@ -41,11 +47,17 @@ MiniPulseView::MiniPulseView(BRect rect, const char *name, Prefs *prefs) :
} }
// These two are only used by DeskbarPulseView, and so do nothing // These two are only used by DeskbarPulseView, and so do nothing
MiniPulseView::MiniPulseView(BRect rect, const char *name) : PulseView(rect, name) { MiniPulseView::MiniPulseView(BRect rect, const char *name)
:
PulseView(rect, name)
{
} }
MiniPulseView::MiniPulseView(BMessage *message) : PulseView(message) { MiniPulseView::MiniPulseView(BMessage *message)
:
PulseView(message)
{
} }
@@ -53,7 +65,8 @@ MiniPulseView::MiniPulseView(BMessage *message) : PulseView(message) {
void MiniPulseView::Draw(BRect rect) { void MiniPulseView::Draw(BRect rect) {
system_info sys_info; system_info sys_info;
get_system_info(&sys_info); get_system_info(&sys_info);
if (sys_info.cpu_count > B_MAX_CPU_COUNT || sys_info.cpu_count <= 0) return; if (sys_info.cpu_count > B_MAX_CPU_COUNT || sys_info.cpu_count <= 0)
return;
BRect bounds(Bounds()); BRect bounds(Bounds());
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);
@@ -70,9 +83,12 @@ void MiniPulseView::Draw(BRect rect) {
double rem = cpu_times[x] * (h + 1) - bar_height; double rem = cpu_times[x] * (h + 1) - bar_height;
rgb_color fraction_color; rgb_color fraction_color;
fraction_color.red = (uint8)(idle_color.red + rem * (active_color.red - idle_color.red)); fraction_color.red = (uint8)(idle_color.red + rem
fraction_color.green = (uint8)(idle_color.green + rem * (active_color.green - idle_color.green)); * (active_color.red - idle_color.red));
fraction_color.blue = (uint8)(idle_color.blue + rem * (active_color.blue - idle_color.blue)); fraction_color.green = (uint8)(idle_color.green + rem
* (active_color.green - idle_color.green));
fraction_color.blue = (uint8)(idle_color.blue + rem
* (active_color.blue - idle_color.blue));
fraction_color.alpha = 0xff; fraction_color.alpha = 0xff;
int idle_height = h - bar_height; int idle_height = h - bar_height;
+12 -6
View File
@@ -1,4 +1,4 @@
//**************************************************************************************** //*****************************************************************************
// //
// File: NormalPulseView.cpp // File: NormalPulseView.cpp
// //
@@ -6,15 +6,17 @@
// //
// Copyright 1999, Be Incorporated // Copyright 1999, Be Incorporated
// //
//**************************************************************************************** //*****************************************************************************
#include "NormalPulseView.h" #include "NormalPulseView.h"
#include "Common.h" #include "Common.h"
#include "Pictures" #include "Pictures"
#include <Catalog.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Dragger.h> #include <Dragger.h>
#include <Locale.h>
#include <Window.h> #include <Window.h>
#include <stdlib.h> #include <stdlib.h>
@@ -23,6 +25,9 @@
#include <cpu_type.h> #include <cpu_type.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "NormalPulseView"
float float
max_font_size(BFont font, const char* text, float maxSize, float maxWidth) max_font_size(BFont font, const char* text, float maxSize, float maxWidth)
@@ -50,9 +55,9 @@ NormalPulseView::NormalPulseView(BRect rect)
SetViewColor(color); SetViewColor(color);
SetLowColor(color); SetLowColor(color);
mode1->SetLabel("Mini mode"); mode1->SetLabel(B_TRANSLATE("Mini mode"));
mode1->SetMessage(new BMessage(PV_MINI_MODE)); mode1->SetMessage(new BMessage(PV_MINI_MODE));
mode2->SetLabel("Deskbar mode"); mode2->SetLabel(B_TRANSLATE("Deskbar mode"));
mode2->SetMessage(new BMessage(PV_DESKBAR_MODE)); mode2->SetMessage(new BMessage(PV_DESKBAR_MODE));
DetermineVendorAndProcessor(); DetermineVendorAndProcessor();
@@ -69,7 +74,8 @@ NormalPulseView::NormalPulseView(BRect rect)
BRect r(PROGRESS_MLEFT, PROGRESS_MTOP + ITEM_OFFSET * x, BRect r(PROGRESS_MLEFT, PROGRESS_MTOP + ITEM_OFFSET * x,
PROGRESS_MLEFT + ProgressBar::PROGRESS_WIDTH, PROGRESS_MLEFT + ProgressBar::PROGRESS_WIDTH,
PROGRESS_MTOP + ITEM_OFFSET * x + ProgressBar::PROGRESS_HEIGHT); PROGRESS_MTOP + ITEM_OFFSET * x + ProgressBar::PROGRESS_HEIGHT);
fProgressBars[x] = new ProgressBar(r, "CPU progress bar"); char* str2 = (char *)B_TRANSLATE("CPU progress bar");
fProgressBars[x] = new ProgressBar(r, str2);
AddChild(fProgressBars[x]); AddChild(fProgressBars[x]);
r.Set(CPUBUTTON_MLEFT, CPUBUTTON_MTOP + ITEM_OFFSET * x, r.Set(CPUBUTTON_MLEFT, CPUBUTTON_MTOP + ITEM_OFFSET * x,
@@ -77,7 +83,7 @@ NormalPulseView::NormalPulseView(BRect rect)
CPUBUTTON_MTOP + ITEM_OFFSET * x + CPUBUTTON_HEIGHT + 7); CPUBUTTON_MTOP + ITEM_OFFSET * x + CPUBUTTON_HEIGHT + 7);
char temp[4]; char temp[4];
sprintf(temp, "%d", x + 1); sprintf(temp, "%d", x + 1);
fCpuButtons[x] = new CPUButton(r, "Pulse", temp, NULL); fCpuButtons[x] = new CPUButton(r, B_TRANSLATE("Pulse"), temp, NULL);
AddChild(fCpuButtons[x]); AddChild(fCpuButtons[x]);
} }
+22 -13
View File
@@ -14,15 +14,21 @@
#include "PulseApp.h" #include "PulseApp.h"
#include "ConfigView.h" #include "ConfigView.h"
#include <Catalog.h>
#include <Button.h> #include <Button.h>
#include <Locale.h>
#include <TabView.h> #include <TabView.h>
#include <TextControl.h> #include <TextControl.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PrefsWindow"
PrefsWindow::PrefsWindow(BRect frame, const char *name, BMessenger *messenger, Prefs *prefs)
PrefsWindow::PrefsWindow(BRect frame, const char *name,
BMessenger *messenger, Prefs *prefs)
: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS), | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS),
fTarget(*messenger), fTarget(*messenger),
@@ -43,16 +49,16 @@ PrefsWindow::PrefsWindow(BRect frame, const char *name, BMessenger *messenger, P
BRect rect = fTabView->ContainerView()->Bounds(); BRect rect = fTabView->ContainerView()->Bounds();
rect.InsetBy(5, 5); rect.InsetBy(5, 5);
ConfigView *normalView = new ConfigView(rect, "Normal mode", ConfigView *normalView = new ConfigView(rect, B_TRANSLATE("Normal mode"),
PRV_NORMAL_CHANGE_COLOR, fTarget, prefs); PRV_NORMAL_CHANGE_COLOR, fTarget, prefs);
fTabView->AddTab(normalView); fTabView->AddTab(normalView);
ConfigView *miniView = new ConfigView(rect, "Mini mode", PRV_MINI_CHANGE_COLOR, ConfigView *miniView = new ConfigView(rect, B_TRANSLATE("Mini mode"),
fTarget, prefs); PRV_MINI_CHANGE_COLOR, fTarget, prefs);
fTabView->AddTab(miniView); fTabView->AddTab(miniView);
ConfigView *deskbarView = new ConfigView(rect, "Deskbar mode", PRV_DESKBAR_CHANGE_COLOR, ConfigView *deskbarView = new ConfigView(rect, B_TRANSLATE("Deskbar mode"),
fTarget, prefs); PRV_DESKBAR_CHANGE_COLOR, fTarget, prefs);
fTabView->AddTab(deskbarView); fTabView->AddTab(deskbarView);
float width, height; float width, height;
@@ -62,18 +68,20 @@ PrefsWindow::PrefsWindow(BRect frame, const char *name, BMessenger *messenger, P
deskbarView->ResizeTo(width, height); deskbarView->ResizeTo(width, height);
fTabView->Select(0L); fTabView->Select(0L);
fTabView->ResizeTo(deskbarView->Bounds().Width() + 16.0f, deskbarView->Bounds().Height() fTabView->ResizeTo(deskbarView->Bounds().Width() + 16.0f,
+ fTabView->ContainerView()->Frame().top + 16.0f); deskbarView->Bounds().Height() +
fTabView->ContainerView()->Frame().top + 16.0f);
BButton *okButton = new BButton(rect, "ok", "OK", new BMessage(PRV_BOTTOM_OK), BButton *okButton = new BButton(rect, "ok", B_TRANSLATE("OK"),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); new BMessage(PRV_BOTTOM_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
okButton->ResizeToPreferred(); okButton->ResizeToPreferred();
okButton->MoveTo(Bounds().Width() - 8.0f - okButton->Bounds().Width(), okButton->MoveTo(Bounds().Width() - 8.0f - okButton->Bounds().Width(),
Bounds().Height() - 8.0f - okButton->Bounds().Height()); Bounds().Height() - 8.0f - okButton->Bounds().Height());
topView->AddChild(okButton); topView->AddChild(okButton);
BButton *defaultsButton = new BButton(okButton->Frame(), "defaults", "Defaults", BButton *defaultsButton = new BButton(okButton->Frame(), "defaults",
new BMessage(PRV_BOTTOM_DEFAULTS), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); B_TRANSLATE("Defaults"), new BMessage(PRV_BOTTOM_DEFAULTS),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
defaultsButton->ResizeToPreferred(); defaultsButton->ResizeToPreferred();
defaultsButton->MoveBy(-defaultsButton->Bounds().Width() - 10.0f, 0.0f); defaultsButton->MoveBy(-defaultsButton->Bounds().Width() - 10.0f, 0.0f);
topView->AddChild(defaultsButton); topView->AddChild(defaultsButton);
@@ -102,7 +110,8 @@ PrefsWindow::MessageReceived(BMessage *message)
Hide(); Hide();
fTabView->Select(2); fTabView->Select(2);
ConfigView *deskbar = (ConfigView *)FindView("Deskbar mode"); ConfigView *deskbar = (ConfigView *)FindView(
B_TRANSLATE("Deskbar mode"));
deskbar->UpdateDeskbarIconWidth(); deskbar->UpdateDeskbarIconWidth();
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
+24 -13
View File
@@ -1,4 +1,4 @@
//**************************************************************************************** //*****************************************************************************
// //
// File: ProgressBar.cpp // File: ProgressBar.cpp
// //
@@ -6,14 +6,15 @@
// //
// Copyright 1999, Be Incorporated // Copyright 1999, Be Incorporated
// //
//**************************************************************************************** //*****************************************************************************
#include "ProgressBar.h" #include "ProgressBar.h"
#include "PulseApp.h" #include "PulseApp.h"
ProgressBar::ProgressBar(BRect r, char *name) : BView(r, name, B_FOLLOW_NONE, B_WILL_DRAW) ProgressBar::ProgressBar(BRect r, char *name) : BView(r, name, B_FOLLOW_NONE,
B_WILL_DRAW)
{ {
previous_value = current_value = 0; previous_value = current_value = 0;
@@ -43,9 +44,12 @@ ProgressBar::UpdateColors(int32 color, bool fade)
unsigned char blue_base = blue / 3; unsigned char blue_base = blue / 3;
for (int x = 0; x < 20; x++) { for (int x = 0; x < 20; x++) {
segments[x].color.red = (uint8)(red_base + ((red - red_base) * ((float)x / 19.0))); segments[x].color.red = (uint8)(red_base + ((red - red_base)
segments[x].color.green = (uint8)(green_base + ((green - green_base) * ((float)x / 19.0))); * ((float)x / 19.0)));
segments[x].color.blue = (uint8)(blue_base + ((blue - blue_base) * ((float)x / 19.0))); segments[x].color.green = (uint8)(green_base
+ ((green - green_base) * ((float)x / 19.0)));
segments[x].color.blue = (uint8)(blue_base + ((blue - blue_base)
* ((float)x / 19.0)));
segments[x].color.alpha = 0xff; segments[x].color.alpha = 0xff;
} }
} else { } else {
@@ -151,15 +155,22 @@ ProgressBar::Draw(BRect rect)
SetHighColor(dkgray, dkgray, dkgray); SetHighColor(dkgray, dkgray, dkgray);
BRect frame = Bounds(); BRect frame = Bounds();
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top)); StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
StrokeLine(BPoint(frame.left, frame.top + 1), BPoint(frame.right, frame.top + 1)); StrokeLine(BPoint(frame.left, frame.top + 1), BPoint(frame.right,
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left, frame.bottom)); frame.top + 1));
StrokeLine(BPoint(frame.left + 1, frame.top), BPoint(frame.left + 1, frame.bottom)); StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left,
frame.bottom));
StrokeLine(BPoint(frame.left + 1, frame.top),
BPoint(frame.left + 1, frame.bottom));
SetHighColor(ltgray, ltgray, ltgray); SetHighColor(ltgray, ltgray, ltgray);
StrokeLine(BPoint(frame.right-1, frame.top + 2), BPoint(frame.right - 1, frame.bottom)); StrokeLine(BPoint(frame.right-1, frame.top + 2),
StrokeLine(BPoint(frame.right, frame.top + 1), BPoint(frame.right, frame.bottom)); BPoint(frame.right - 1, frame.bottom));
StrokeLine(BPoint(frame.left+1, frame.bottom - 1), BPoint(frame.right - 1, frame.bottom - 1)); StrokeLine(BPoint(frame.right, frame.top + 1),
StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.right, frame.bottom)); BPoint(frame.right, frame.bottom));
StrokeLine(BPoint(frame.left+1, frame.bottom - 1),
BPoint(frame.right - 1, frame.bottom - 1));
StrokeLine(BPoint(frame.left, frame.bottom),
BPoint(frame.right, frame.bottom));
Render(true); Render(true);
} }
+13 -4
View File
@@ -19,8 +19,10 @@
#include <getopt.h> #include <getopt.h>
#include <Alert.h> #include <Alert.h>
#include <Rect.h> #include <Catalog.h>
#include <Deskbar.h> #include <Deskbar.h>
#include <Locale.h>
#include <Rect.h>
#include <syscalls.h> #include <syscalls.h>
@@ -28,6 +30,9 @@
#include "PulseWindow.h" #include "PulseWindow.h"
#include "DeskbarPulseView.h" #include "DeskbarPulseView.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PulseApp"
PulseApp::PulseApp(int argc, char **argv) PulseApp::PulseApp(int argc, char **argv)
: BApplication(APP_SIGNATURE) : BApplication(APP_SIGNATURE)
@@ -197,9 +202,9 @@ GetMinimumViewWidth()
void void
Usage() Usage()
{ {
printf("Usage: Pulse [--mini] [-w width] [--width=width]\n" printf(B_TRANSLATE("Usage: Pulse [--mini] [-w width] [--width=width]\n"
"\t[--deskbar] [--normal] [--framecolor 0xrrggbb]\n" "\t[--deskbar] [--normal] [--framecolor 0xrrggbb]\n"
"\t[--activecolor 0xrrggbb] [--idlecolor 0xrrggbb]\n"); "\t[--activecolor 0xrrggbb] [--idlecolor 0xrrggbb]\n"));
exit(0); exit(0);
} }
@@ -229,7 +234,7 @@ LoadInDeskbar()
delete replicant; delete replicant;
delete deskbar; delete deskbar;
if (err != B_OK) { if (err != B_OK) {
BAlert *alert = new BAlert(NULL, strerror(err), "OK"); BAlert *alert = new BAlert(NULL, strerror(err), B_TRANSLATE("OK"));
alert->Go(NULL); alert->Go(NULL);
return false; return false;
} }
@@ -241,6 +246,10 @@ LoadInDeskbar()
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
BCatalog fAppCatalog;
be_locale->GetAppCatalog(&fAppCatalog);
PulseApp *pulseapp = new PulseApp(argc, argv); PulseApp *pulseapp = new PulseApp(argc, argv);
pulseapp->Run(); pulseapp->Run();
delete pulseapp; delete pulseapp;
+11 -3
View File
@@ -15,12 +15,17 @@
#include <string.h> #include <string.h>
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <Locale.h>
#include <syscalls.h> #include <syscalls.h>
#include "Common.h" #include "Common.h"
#include "PulseApp.h" #include "PulseApp.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PulseView"
PulseView::PulseView(BRect rect, const char *name) : PulseView::PulseView(BRect rect, const char *name) :
BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) { BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) {
@@ -50,8 +55,10 @@ void PulseView::Init() {
popupmenu->SetFont(be_plain_font); popupmenu->SetFont(be_plain_font);
mode1 = new BMenuItem("", NULL, 0, 0); mode1 = new BMenuItem("", NULL, 0, 0);
mode2 = new BMenuItem("", NULL, 0, 0); mode2 = new BMenuItem("", NULL, 0, 0);
preferences = new BMenuItem("Settings" B_UTF8_ELLIPSIS, new BMessage(PV_PREFERENCES), 0, 0); preferences = new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
about = new BMenuItem("About Pulse" B_UTF8_ELLIPSIS, new BMessage(PV_ABOUT), 0, 0); new BMessage(PV_PREFERENCES), 0, 0);
about = new BMenuItem(B_TRANSLATE("About Pulse" B_UTF8_ELLIPSIS),
new BMessage(PV_ABOUT), 0, 0);
popupmenu->AddItem(mode1); popupmenu->AddItem(mode1);
popupmenu->AddItem(mode2); popupmenu->AddItem(mode2);
@@ -121,7 +128,8 @@ void PulseView::ChangeCPUState(BMessage *message) {
if (!LastEnabledCPU(which)) { if (!LastEnabledCPU(which)) {
_kern_set_cpu_enabled(which, (int)!cpu_menu_items[which]->IsMarked()); _kern_set_cpu_enabled(which, (int)!cpu_menu_items[which]->IsMarked());
} else { } else {
BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); BAlert *alert = new BAlert(NULL, B_TRANSLATE("You can't disable the "
"last active CPU."), B_TRANSLATE("OK"));
alert->Go(NULL); alert->Go(NULL);
} }
} }
+16 -5
View File
@@ -1,4 +1,4 @@
//**************************************************************************************** //*****************************************************************************
// //
// File: PulseWindow.cpp // File: PulseWindow.cpp
// //
@@ -6,7 +6,7 @@
// //
// Copyright 1999, Be Incorporated // Copyright 1999, Be Incorporated
// //
//**************************************************************************************** //*****************************************************************************
#include "PulseWindow.h" #include "PulseWindow.h"
@@ -15,24 +15,32 @@
#include "DeskbarPulseView.h" #include "DeskbarPulseView.h"
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <Deskbar.h> #include <Deskbar.h>
#include <Locale.h>
#include <Screen.h> #include <Screen.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PulseWindow"
PulseWindow::PulseWindow(BRect rect) : PulseWindow::PulseWindow(BRect rect) :
BWindow(rect, "Pulse", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) BWindow(rect, "Pulse", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{ {
SetPulseRate(200000); SetPulseRate(200000);
SetTitle(B_TRANSLATE("Pulse"));
PulseApp *pulseapp = (PulseApp *)be_app; PulseApp *pulseapp = (PulseApp *)be_app;
BRect bounds = Bounds(); BRect bounds = Bounds();
fNormalPulseView = new NormalPulseView(bounds); fNormalPulseView = new NormalPulseView(bounds);
AddChild(fNormalPulseView); AddChild(fNormalPulseView);
fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView", pulseapp->prefs); fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView",
pulseapp->prefs);
AddChild(fMiniPulseView); AddChild(fMiniPulseView);
fMode = pulseapp->prefs->window_mode; fMode = pulseapp->prefs->window_mode;
@@ -89,12 +97,15 @@ PulseWindow::MessageReceived(BMessage *message)
// Otherwise launch a new preferences window // Otherwise launch a new preferences window
PulseApp *pulseapp = (PulseApp *)be_app; PulseApp *pulseapp = (PulseApp *)be_app;
fPrefsWindow = new PrefsWindow(pulseapp->prefs->prefs_window_rect, fPrefsWindow = new PrefsWindow(pulseapp->prefs->prefs_window_rect,
"Pulse settings", new BMessenger(this), pulseapp->prefs); B_TRANSLATE("Pulse settings"), new BMessenger(this),
pulseapp->prefs);
fPrefsWindow->Show(); fPrefsWindow->Show();
break; break;
} }
case PV_ABOUT: { case PV_ABOUT: {
BAlert *alert = new BAlert("Info", "Pulse\n\nBy David Ramsey and Arve Hjønnevåg\nRevised by Daniel Switkin", "OK"); BAlert *alert = new BAlert(B_TRANSLATE("Info"),
B_TRANSLATE("Pulse\n\nBy David Ramsey and Arve Hjønnevåg\n"
"Revised by Daniel Switkin"), B_TRANSLATE("OK"));
// Use the asynchronous version so we don't block the window's thread // Use the asynchronous version so we don't block the window's thread
alert->Go(NULL); alert->Go(NULL);
break; break;