Skip to content

Commit ba389cd

Browse files
committed
vmware_tray: Add initial localization support.
Also: switched the "About..." from a BAlert to a BAboutWindow.
1 parent af9d974 commit ba389cd

File tree

10 files changed

+182
-47
lines changed

10 files changed

+182
-47
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ build:
1919
make -C vmware_fs
2020
make -C vmware_mouse
2121
make -C vmware_tray
22+
make -C vmware_tray bindcatalogs
2223
make -C vmware_video/accelerant
2324
make -C vmware_video/kernel
2425

2526
release:
2627
make RELEASE=1 -C vmware_fs
2728
make RELEASE=1 -C vmware_mouse
2829
make RELEASE=1 -C vmware_tray
30+
make RELEASE=1 -C vmware_tray bindcatalogs
2931
make RELEASE=1 -C vmware_video/accelerant
3032
make RELEASE=1 -C vmware_video/kernel
3133

vmware_tray/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ NAME= vmware_tray
1616
# DRIVER: Kernel Driver
1717
TYPE= APP
1818

19+
APP_MIME_SIG = application/x-vnd.VinDuv.VMwareAddOns
20+
1921
# add support for new Pe and Eddie features
2022
# to fill in generic makefile
2123

@@ -58,7 +60,7 @@ RSRCS=
5860
# naming scheme you need to specify the path to the library
5961
# and it's name
6062
# library: my_lib.a entry: my_lib.a or path/my_lib.a
61-
LIBS= be $(STDCPPLIBS)
63+
LIBS= be localestub $(STDCPPLIBS)
6264

6365
# specify additional paths to directories following the standard
6466
# libXXX.so or libXXX.a naming scheme. You can specify full paths
@@ -71,7 +73,8 @@ LIBPATHS=
7173
# additional paths to look for system headers
7274
# thes use the form: #include <header>
7375
# source file directories are NOT auto-included here
74-
SYSTEM_INCLUDE_PATHS =
76+
SYSTEM_INCLUDE_PATHS = \
77+
$(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface)
7578

7679
# additional paths to look for local headers
7780
# thes use the form: #include "header"
@@ -82,6 +85,13 @@ LOCAL_INCLUDE_PATHS = ../shared_sources/
8285
# NONE, SOME, FULL
8386
OPTIMIZE= SOME
8487

88+
# Specify the codes for languages you are going to support in this
89+
# application. The default "en" one must be provided too. "make catkeys"
90+
# will recreate only the "locales/en.catkeys" file. Use it as a template
91+
# for creating catkeys for other languages. All localization files must be
92+
# placed in the "locales" subdirectory.
93+
LOCALES = en es_419 es
94+
8595
# specify any preprocessor symbols to be defined. The symbols will not
8696
# have their values set automatically; you must supply the value (if any)
8797
# to use. For example, setting DEFINES to "DEBUG=1" will cause the

vmware_tray/VMWAddOns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Application constants
1010
#define APP_SIG "application/x-vnd.VinDuv.VMwareAddOns"
11-
#define APP_NAME "VMWare Add-ons"
11+
#define APP_NAME "VMware Add-ons"
1212
#define APP_VERSION "1.2.2"
1313
#define TRAY_NAME "vmware add-ons"
1414

vmware_tray/VMWAddOnsCleanup.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
#include "VMWAddOnsCleanup.h"
77

88
#include <Alert.h>
9+
#include <Catalog.h>
910

1011
#include "VMWAddOnsSelectWindow.h"
1112
#include "VMWAddOnsStatusWindow.h"
1213
#include "VMWAddOnsTray.h"
1314

1415

16+
#undef B_TRANSLATION_CONTEXT
17+
#define B_TRANSLATION_CONTEXT "Virtual Disk Shrinking"
18+
1519
#define MB (1024 * 1024)
1620
#define BUF_SIZE (MB / 2)
1721
#define MAX_FILES 200
@@ -58,11 +62,13 @@ VMWAddOnsCleanup::ThreadLoop()
5862
break;
5963

6064
if (ret != B_DEVICE_FULL && ret != B_OK) {
61-
(new BAlert("Error",
62-
(BString("An error occurred while cleaning ”")
63-
<< name << "” (" << strerror(ret) << "). This volume may be damaged.")
64-
.String(),
65-
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))
65+
BString alertText;
66+
alertText.SetToFormat(B_TRANSLATE_COMMENT("An error occurred while cleaning %s (%s). "
67+
"This volume may be damaged.",
68+
"First %s is the name of the volume being cleaned. Second %s is the error message."),
69+
name, strerror(ret));
70+
(new BAlert(B_TRANSLATE("Error"), alertText.String(),
71+
B_TRANSLATE("Ok"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))
6672
->Go();
6773
}
6874
}
@@ -80,12 +86,14 @@ VMWAddOnsCleanup::Start(void* data)
8086
{
8187
VMWAddOnsTray* parentTray = (VMWAddOnsTray*)data;
8288

83-
int32 result = (new BAlert("Shrink disks",
84-
"Disk shrinking will operate on all auto-expanding disks "
89+
int32 result = (new BAlert(B_TRANSLATE("Shrink disks"),
90+
B_TRANSLATE("Disk shrinking will operate on all auto-expanding disks "
8591
"attached to this virtual machine.\nFor best results it is "
86-
"recommanded to clean up free space on these disks before starting "
87-
"the process.\n",
88-
"Cancel", "Shrink now" B_UTF8_ELLIPSIS, "Clean up disks" B_UTF8_ELLIPSIS,
92+
"recommended to clean up free space on these disks before starting "
93+
"the process.\n"),
94+
B_TRANSLATE("Cancel"),
95+
B_TRANSLATE("Shrink now" B_UTF8_ELLIPSIS),
96+
B_TRANSLATE("Clean up disks" B_UTF8_ELLIPSIS),
8997
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT))
9098
->Go();
9199

@@ -104,11 +112,11 @@ VMWAddOnsCleanup::Start(void* data)
104112
}
105113
}
106114

107-
result = (new BAlert("Shrink disks",
108-
"The shrink operation will now be launched in VMWare."
109-
"This may take a long time ; the virtual machine will be "
110-
"suspended during the process.",
111-
"Cancel", "OK"))
115+
result = (new BAlert(B_TRANSLATE("Shrink disks"),
116+
B_TRANSLATE("The shrink operation will now be launched in VMware. "
117+
"This may take a long time; the virtual machine will be "
118+
"suspended during the process."),
119+
B_TRANSLATE("Cancel"), B_TRANSLATE("OK")))
112120
->Go();
113121

114122
// OK...

vmware_tray/VMWAddOnsSelectWindow.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77

88
#include <stdlib.h>
99

10+
#include <Catalog.h>
1011
#include <NodeMonitor.h>
1112
#include <Screen.h>
1213
#include <ScrollView.h>
1314

1415
#include "VMWAddOnsCleanup.h"
1516

17+
18+
#undef B_TRANSLATION_CONTEXT
19+
#define B_TRANSLATION_CONTEXT "Virtual Disk Shrinking"
20+
1621
#define _H(x) static_cast<int>((x)->Frame().Height())
1722
#define _W(x) static_cast<int>((x)->Frame().Width())
1823

@@ -25,7 +30,7 @@
2530

2631
VMWAddOnsSelectWindow::VMWAddOnsSelectWindow()
2732
:
28-
BWindow(BRect(0, 0, 300, 1), "Clean up free space", B_TITLED_WINDOW,
33+
BWindow(BRect(0, 0, 300, 1), B_TRANSLATE("Clean up free space"), B_TITLED_WINDOW,
2934
B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
3035
{
3136
fVolumeRoster = new BVolumeRoster();
@@ -35,7 +40,7 @@ VMWAddOnsSelectWindow::VMWAddOnsSelectWindow()
3540
fDisksView = new BView(Bounds(), "disks view", B_FOLLOW_ALL, B_WILL_DRAW);
3641
fDisksView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
3742

38-
fInfoText = new BStringView(BRect(SPACING, y, 1, 1), NULL, "Volumes to cleanup :");
43+
fInfoText = new BStringView(BRect(SPACING, y, 1, 1), NULL, B_TRANSLATE("Volumes to clean up:"));
3944
fInfoText->ResizeToPreferred();
4045
y += _H(fInfoText) + SPACING;
4146
if (w < _W(fInfoText))
@@ -66,7 +71,7 @@ VMWAddOnsSelectWindow::VMWAddOnsSelectWindow()
6671

6772
fDisksView->AddChild(new BScrollView(NULL, fVolumesList, B_FOLLOW_ALL_SIDES, 0, false, true));
6873

69-
fCleanupButton = new BButton(BRect(0, 0, 0, 0), NULL, "Cleanup selection",
74+
fCleanupButton = new BButton(BRect(0, 0, 0, 0), NULL, B_TRANSLATE("Clean up selection"),
7075
new BMessage(CLEANUP_SELECTION), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
7176
fCleanupButton->MakeDefault(true);
7277
fCleanupButton->SetEnabled(fVolumesList->CurrentSelection() >= 0);
@@ -77,8 +82,8 @@ VMWAddOnsSelectWindow::VMWAddOnsSelectWindow()
7782

7883
fCleanupButton->SetEnabled(fVolumesList->CurrentSelection() >= 0);
7984

80-
fCancelButton = new BButton(BRect(0, 0, 0, 0), NULL, "Cancel", new BMessage(CANCEL_OPERATION),
81-
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
85+
fCancelButton = new BButton(BRect(0, 0, 0, 0), NULL, B_TRANSLATE("Cancel"),
86+
new BMessage(CANCEL_OPERATION), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
8287
fCancelButton->ResizeToPreferred();
8388
fCancelButton->MoveTo(w - _W(fCleanupButton) - _W(fCancelButton), y + 3);
8489

vmware_tray/VMWAddOnsStatusWindow.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
#include "VMWAddOnsStatusWindow.h"
77

8+
#include <Catalog.h>
89
#include <Screen.h>
910
#include <String.h>
1011

1112

13+
#undef B_TRANSLATION_CONTEXT
14+
#define B_TRANSLATION_CONTEXT "Virtual Disk Shrinking"
15+
1216
#define _H(x) static_cast<int>((x)->Frame().Height())
1317
#define _W(x) static_cast<int>((x)->Frame().Width())
1418

@@ -19,19 +23,20 @@
1923

2024
VMWAddOnsStatusWindow::VMWAddOnsStatusWindow()
2125
:
22-
BWindow(BRect(0, 0, 300, 400), "Progress", B_TITLED_WINDOW,
26+
BWindow(BRect(0, 0, 300, 400), B_TRANSLATE("Progress"), B_TITLED_WINDOW,
2327
B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
2428
{
2529
fStatusView = new BView(Bounds(), "cleanup view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
2630
fStatusView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
2731

2832
fProgressBar = new BStatusBar(BRect(SPACING, SPACING, 200, 45), NULL,
29-
"Starting cleanup process, please wait...");
33+
B_TRANSLATE("Starting cleanup process, please wait" B_UTF8_ELLIPSIS));
3034
fProgressBar->ResizeToPreferred();
3135

3236
fStatusView->AddChild(fProgressBar);
3337

34-
fStopButton = new BButton(BRect(0, 0, 0, 0), NULL, "Stop", new BMessage(STOP_OPERATION));
38+
fStopButton = new BButton(BRect(0, 0, 0, 0), NULL, B_TRANSLATE("Stop"),
39+
new BMessage(STOP_OPERATION));
3540
fStopButton->ResizeToPreferred();
3641

3742
fStopButton->MoveTo(2 * SPACING + _W(fProgressBar),
@@ -73,7 +78,10 @@ VMWAddOnsStatusWindow::MessageReceived(BMessage* message)
7378

7479
off_t size = sizeRead;
7580

76-
fProgressBar->Reset((BString("Cleaning up “") << name << "" B_UTF8_ELLIPSIS).String());
81+
BString text;
82+
text.SetToFormat(B_TRANSLATE_COMMENT("Cleaning up %s" B_UTF8_ELLIPSIS,
83+
"%s is the name of the volume being cleaned."), name);
84+
fProgressBar->Reset(text.String());
7785
fProgressBar->SetMaxValue(size);
7886
}
7987

vmware_tray/VMWAddOnsTray.cpp

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
#include "VMWAddOnsTray.h"
77

8+
#include <AboutWindow.h>
89
#include <Alert.h>
10+
#include <Catalog.h>
911
#include <Deskbar.h>
1012
#include <MenuItem.h>
1113
#include <Mime.h>
@@ -17,6 +19,9 @@
1719
#include "icons.h"
1820

1921

22+
#undef B_TRANSLATION_CONTEXT
23+
#define B_TRANSLATION_CONTEXT "Deskbar tray icon"
24+
2025
#define CLIP_POLL_DELAY 1000000
2126
#define CLOCK_POLL_DELAY 60000000
2227

@@ -193,13 +198,10 @@ VMWAddOnsTray::MessageReceived(BMessage* message)
193198

194199
case B_ABOUT_REQUESTED:
195200
{
196-
BAlert* alert = new BAlert("about",
197-
APP_NAME ", version " APP_VERSION "\n"
198-
"© 2009, Vincent Duvert\n"
199-
"Distributed under the terms of the MIT License.",
200-
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
201-
alert->SetShortcut(0, B_ENTER);
202-
alert->Go(NULL);
201+
BAboutWindow* window = new BAboutWindow("VMware Add-ons",
202+
"application/x-vnd.VinDuv.VMwareAddOns");
203+
window->AddCopyright(2009, "Vincent Duvert");
204+
window->Show();
203205
} break;
204206

205207
case B_CLIPBOARD_CHANGED:
@@ -338,9 +340,9 @@ VMWAddOnsTray::StartShrink()
338340
fBackdoor.CloseRPCChannel();
339341
} else {
340342
(new BAlert(TRAY_NAME,
341-
"Unable to communicate with VMWare. Your VMWare version may be too old. Please start "
342-
"the process manually if your VMware version allows it.",
343-
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))
343+
B_TRANSLATE("Unable to communicate with VMware. Your VMware version may be too old. "
344+
"Please start the process manually if your VMware version allows it."),
345+
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))
344346
->Go();
345347
}
346348
}
@@ -355,9 +357,12 @@ VMWAddOnsTray::RemoveMyself(bool askUser)
355357
int32 result = 1;
356358
if (askUser) {
357359
result = (new BAlert(TRAY_NAME,
358-
"Are you sure you want to quit?\n"
359-
"This will stop clipboard sharing (but not mouse sharing if it is running).",
360-
"Cancel", "Quit", NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT))
360+
B_TRANSLATE("Are you sure you want to quit?\n"
361+
"This will stop clipboard sharing, and time synchronization "
362+
"(but not the mouse sharing, if it is currently enabled)."),
363+
B_TRANSLATE("Cancel"),
364+
B_TRANSLATE("Quit"),
365+
NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT))
361366
->Go();
362367
}
363368

@@ -382,21 +387,24 @@ VMWAddOnsMenu::VMWAddOnsMenu(VMWAddOnsTray* tray, VMWBackdoor& fBackdoor)
382387
SetFont(be_plain_font);
383388

384389
if (fBackdoor.InVMware()) {
385-
menuItem = new BMenuItem("Enable mouse sharing", new BMessage(MOUSE_SHARING));
390+
menuItem = new BMenuItem(B_TRANSLATE("Enable mouse sharing"), new BMessage(MOUSE_SHARING));
386391
if (fBackdoor.GetGUISetting(VMWBackdoor::POINTER_GRAB_UNGRAB))
387392
menuItem->SetMarked(gSettings.GetBool("mouse_enabled", true));
388393
else
389394
menuItem->SetMarked(false);
390395
AddItem(menuItem);
391396

392-
menuItem = new BMenuItem("Enable clipboard sharing", new BMessage(CLIPBOARD_SHARING));
397+
menuItem = new BMenuItem(B_TRANSLATE("Enable clipboard sharing"),
398+
new BMessage(CLIPBOARD_SHARING));
393399
if (fBackdoor.GetGUISetting(VMWBackdoor::CLIP_BOARD_SHARING))
394400
menuItem->SetMarked(gSettings.GetBool("clip_enabled", true));
395401
else
396402
menuItem->SetMarked(false);
397403
AddItem(menuItem);
398404

399-
menuItem = new BMenuItem("Enable time synchronization", new BMessage(TIMESYNC_HOST));
405+
menuItem = new BMenuItem(B_TRANSLATE_COMMENT("Enable time synchronization",
406+
"Alternatively: \"Synchronize clock\"."),
407+
new BMessage(TIMESYNC_HOST));
400408
if (fBackdoor.GetGUISetting(VMWBackdoor::TIME_SYNC))
401409
menuItem->SetMarked(gSettings.GetBool("timesync_enabled", true));
402410
else
@@ -405,18 +413,22 @@ VMWAddOnsMenu::VMWAddOnsMenu(VMWAddOnsTray* tray, VMWBackdoor& fBackdoor)
405413

406414
if (!tray->fCleanupInProgress) {
407415
AddItem(
408-
new BMenuItem("Shrink virtual disks " B_UTF8_ELLIPSIS, new BMessage(SHRINK_DISKS)));
416+
new BMenuItem(B_TRANSLATE("Shrink virtual disks" B_UTF8_ELLIPSIS),
417+
new BMessage(SHRINK_DISKS))
418+
);
409419
}
410420
} else {
411-
menuItem = new BMenuItem("Not running in VMware", NULL);
421+
menuItem = new BMenuItem(B_TRANSLATE_COMMENT("Not running in VMware",
422+
"Alternatively: \"VMware not detected\"."), NULL);
412423
menuItem->SetEnabled(false);
413424
AddItem(menuItem);
414425
}
415426

416427
AddSeparatorItem();
417428

418-
AddItem(new BMenuItem("About " APP_NAME B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED)));
419-
AddItem(new BMenuItem("Quit" B_UTF8_ELLIPSIS, new BMessage(REMOVE_FROM_DESKBAR)));
429+
AddItem(new BMenuItem(B_TRANSLATE("About " APP_NAME B_UTF8_ELLIPSIS),
430+
new BMessage(B_ABOUT_REQUESTED)));
431+
AddItem(new BMenuItem(B_TRANSLATE("Quit" B_UTF8_ELLIPSIS), new BMessage(REMOVE_FROM_DESKBAR)));
420432

421433
SetTargetForItems(tray);
422434
SetAsyncAutoDestruct(true);

vmware_tray/locales/en.catkeys

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
1 English application/x-vnd.VinDuv.VMwareAddOns 760284408
2+
Enable time synchronization Deskbar tray icon Alternatively: \"Synchronize clock\". Enable time synchronization
3+
Shrink now… Virtual Disk Shrinking Shrink now…
4+
Clean up selection Virtual Disk Shrinking Clean up selection
5+
OK Virtual Disk Shrinking OK
6+
Cancel Deskbar tray icon Cancel
7+
Disk shrinking will operate on all auto-expanding disks attached to this virtual machine.\nFor best results it is recommended to clean up free space on these disks before starting the process.\n Virtual Disk Shrinking Disk shrinking will operate on all auto-expanding disks attached to this virtual machine.\nFor best results it is recommended to clean up free space on these disks before starting the process.\n
8+
Quit… Deskbar tray icon Quit…
9+
Starting cleanup process, please wait… Virtual Disk Shrinking Starting cleanup process, please wait…
10+
Are you sure you want to quit?\nThis will stop clipboard sharing, and time synchronization (but not the mouse sharing, if it is currently enabled). Deskbar tray icon Are you sure you want to quit?\nThis will stop clipboard sharing, and time synchronization (but not the mouse sharing, if it is currently enabled).
11+
Shrink virtual disks… Deskbar tray icon Shrink virtual disks…
12+
Volumes to clean up: Virtual Disk Shrinking Volumes to clean up:
13+
Shrink disks Virtual Disk Shrinking Shrink disks
14+
An error occurred while cleaning %s (%s). This volume may be damaged. Virtual Disk Shrinking First %s is the name of the volume being cleaned. Second %s is the error message. An error occurred while cleaning %s (%s). This volume may be damaged.
15+
Clean up disks… Virtual Disk Shrinking Clean up disks…
16+
Stop Virtual Disk Shrinking Stop
17+
Cancel Virtual Disk Shrinking Cancel
18+
Ok Virtual Disk Shrinking Ok
19+
OK Deskbar tray icon OK
20+
Progress Virtual Disk Shrinking Progress
21+
About VMware Add-ons… Deskbar tray icon About VMware Add-ons…
22+
Clean up free space Virtual Disk Shrinking Clean up free space
23+
Cleaning up %s… Virtual Disk Shrinking %s is the name of the volume being cleaned. Cleaning up %s…
24+
Enable mouse sharing Deskbar tray icon Enable mouse sharing
25+
Error Virtual Disk Shrinking Error
26+
Not running in VMware Deskbar tray icon Alternatively: \"VMware not detected\". Not running in VMware
27+
Unable to communicate with VMware. Your VMware version may be too old. Please start the process manually if your VMware version allows it. Deskbar tray icon Unable to communicate with VMware. Your VMware version may be too old. Please start the process manually if your VMware version allows it.
28+
The shrink operation will now be launched in VMware. This may take a long time; the virtual machine will be suspended during the process. Virtual Disk Shrinking The shrink operation will now be launched in VMware. This may take a long time; the virtual machine will be suspended during the process.
29+
Enable clipboard sharing Deskbar tray icon Enable clipboard sharing
30+
Quit Deskbar tray icon Quit

0 commit comments

Comments
 (0)