Patch by mt : localize expander.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35577 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2010-02-22 21:14:39 +00:00
parent 0497cb9f12
commit ab7b656898
6 changed files with 183 additions and 209 deletions

View File

@ -9,6 +9,8 @@
#include "DirectoryFilePanel.h" #include "DirectoryFilePanel.h"
#include <Catalog.h>
#include <Locale.h>
#include <Window.h> #include <Window.h>
#include <stdio.h> #include <stdio.h>
@ -41,10 +43,13 @@ DirectoryRefFilter::Filter(const entry_ref *ref, BNode* node,
// #pragma mark - // #pragma mark -
#undef TR_CONTEXT
#define TR_CONTEXT "DirectoryFilePanel"
DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger *target,
const entry_ref *startDirectory, uint32 nodeFlavors, DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode, BMessenger* target,
bool allowMultipleSelection, BMessage *message, BRefFilter *filter, const entry_ref* startDirectory, uint32 nodeFlavors,
bool allowMultipleSelection, BMessage* message, BRefFilter* filter,
bool modal, bool hideWhenDone) bool modal, bool hideWhenDone)
: BFilePanel(mode, target, startDirectory, nodeFlavors, : BFilePanel(mode, target, startDirectory, nodeFlavors,
allowMultipleSelection, message, filter, modal, hideWhenDone), allowMultipleSelection, message, filter, modal, hideWhenDone),
@ -72,16 +77,16 @@ DirectoryFilePanel::Show()
} }
rect.right = rect.left -= 30; rect.right = rect.left -= 30;
float width = be_plain_font->StringWidth("Select current") + 20; float width = be_plain_font->StringWidth(TR("Select current")) + 20;
rect.left = width > 75 ? rect.right - width : rect.right - 75; rect.left = width > 75 ? rect.right - width : rect.right - 75;
fCurrentButton = new BButton(rect, "directoryButton", "Select current", fCurrentButton = new BButton(rect, "directoryButton", TR("Select current"),
new BMessage(MSG_DIRECTORY), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); new BMessage(MSG_DIRECTORY), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
background->AddChild(fCurrentButton); background->AddChild(fCurrentButton);
fCurrentButton->SetTarget(Messenger()); fCurrentButton->SetTarget(Messenger());
SetButtonLabel(B_DEFAULT_BUTTON, "Select"); SetButtonLabel(B_DEFAULT_BUTTON, TR("Select"));
Window()->SetTitle("Expander: Choose destination"); Window()->SetTitle(TR("Expander: Choose destination"));
Window()->Unlock(); Window()->Unlock();
@ -100,8 +105,9 @@ DirectoryFilePanel::SelectionChanged()
char label[64]; char label[64];
entry_ref ref; entry_ref ref;
GetPanelDirectory(&ref); GetPanelDirectory(&ref);
if (snprintf(label, sizeof(label), "Select '%s'", ref.name) >= (int)sizeof(label)) if (snprintf(label, sizeof(label),
strcpy(label + sizeof(label) - 5, B_UTF8_ELLIPSIS "'"); TR("Select '%s'"), ref.name) >= (int)sizeof(label))
strcpy(label + sizeof(label) - 5, B_UTF8_ELLIPSIS "'");
// Resize button so that the label fits // Resize button so that the label fits
// maximum width is dictated by the window's size limits // maximum width is dictated by the window's size limits

View File

@ -8,12 +8,15 @@
#include "ExpanderWindow.h" #include "ExpanderWindow.h"
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <Locale.h>
#include <TextView.h> #include <TextView.h>
ExpanderApp::ExpanderApp() ExpanderApp::ExpanderApp()
: BApplication("application/x-vnd.Haiku-Expander") : BApplication("application/x-vnd.Haiku-Expander")
{ {
be_locale->GetAppCatalog(&fCatalog);
BPoint windowPosition = fSettings.Message().FindPoint("window_position"); BPoint windowPosition = fSettings.Message().FindPoint("window_position");
BRect windowFrame(0, 0, 450, 120); BRect windowFrame(0, 0, 450, 120);
windowFrame.OffsetBy(windowPosition); windowFrame.OffsetBy(windowPosition);
@ -22,15 +25,16 @@ ExpanderApp::ExpanderApp()
} }
#undef TR_CONTEXT
#define TR_CONTEXT "About"
void void
ExpanderApp::AboutRequested() ExpanderApp::AboutRequested()
{ {
BAlert *alert = new BAlert("about", "Expander\n" BAlert* alert = new BAlert("about",
"\twritten by Jérôme Duval\n" TR("Expander\n\twritten by Jérôme Duval\n\tCopyright 2004-2006, Haiku Inc.\n\noriginal Be version by \nDominic, Hiroshi, Peter, Pavel and Robert\n"),
"\tCopyright 2004-2006, Haiku Inc.\n\n" TR("OK"));
"original Be version by \n" BTextView* view = alert->TextView();
"Dominic, Hiroshi, Peter, Pavel and Robert\n", "OK");
BTextView *view = alert->TextView();
BFont font; BFont font;
view->SetStylable(true); view->SetStylable(true);
@ -53,7 +57,7 @@ ExpanderApp::ReadyToRun()
void void
ExpanderApp::ArgvReceived(int32 argc, char **argv) ExpanderApp::ArgvReceived(int32 argc, char **argv)
{ {
BMessage *msg = NULL; BMessage* msg = NULL;
for (int32 i = 1; i < argc; i++) { for (int32 i = 1; i < argc; i++) {
entry_ref ref; entry_ref ref;
status_t err = get_ref_for_path(argv[i], &ref); status_t err = get_ref_for_path(argv[i], &ref);
@ -71,7 +75,7 @@ ExpanderApp::ArgvReceived(int32 argc, char **argv)
void void
ExpanderApp::RefsReceived(BMessage *msg) ExpanderApp::RefsReceived(BMessage* msg)
{ {
BMessenger messenger(fWindow); BMessenger messenger(fWindow);
msg->AddBool("fromApp", true); msg->AddBool("fromApp", true);
@ -80,7 +84,7 @@ ExpanderApp::RefsReceived(BMessage *msg)
void void
ExpanderApp::UpdateSettingsFrom(BMessage *message) ExpanderApp::UpdateSettingsFrom(BMessage* message)
{ {
fSettings.UpdateFrom(message); fSettings.UpdateFrom(message);
} }

View File

@ -30,6 +30,7 @@
#define _ExpanderApp_h #define _ExpanderApp_h
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include "ExpanderSettings.h" #include "ExpanderSettings.h"
#include "ExpanderWindow.h" #include "ExpanderWindow.h"
@ -47,6 +48,7 @@ class ExpanderApp : public BApplication {
void UpdateSettingsFrom(BMessage *message); void UpdateSettingsFrom(BMessage *message);
private: private:
ExpanderWindow *fWindow; ExpanderWindow *fWindow;
BCatalog fCatalog;
}; };
#endif /* _ExpanderApp_h */ #endif /* _ExpanderApp_h */

View File

@ -5,6 +5,10 @@
#include "ExpanderPreferences.h" #include "ExpanderPreferences.h"
#include <Box.h> #include <Box.h>
#include <Catalog.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <Path.h> #include <Path.h>
#include <Screen.h> #include <Screen.h>
#include <StringView.h> #include <StringView.h>
@ -17,169 +21,101 @@ const uint32 MSG_DESTUSE = 'mDeu';
const uint32 MSG_DESTTEXT = 'mDet'; const uint32 MSG_DESTTEXT = 'mDet';
const uint32 MSG_DESTSELECT = 'mDes'; const uint32 MSG_DESTSELECT = 'mDes';
#undef TR_CONTEXT
#define TR_CONTEXT "ExpanderPreferences"
ExpanderPreferences::ExpanderPreferences(BMessage *settings) ExpanderPreferences::ExpanderPreferences(BMessage *settings)
: BWindow(BRect(0, 0, 325, 305), "Expander", B_MODAL_WINDOW, : BWindow(BRect(0, 0, 325, 305), "Expander", B_MODAL_WINDOW,
B_NOT_CLOSABLE | B_NOT_RESIZABLE), B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fSettings(settings), fSettings(settings),
fUsePanel(NULL) fUsePanel(NULL)
{ {
BBox* box = new BBox("background");
box->SetLabel(TR("Expander settings"));
BRect rect = Bounds(); fAutoExpand = new BCheckBox("autoExpand",
BBox *background = new BBox(rect, "background", B_FOLLOW_ALL, TR("Automatically expand files"), NULL);
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); fCloseWindow = new BCheckBox("closeWindowWhenDone",
AddChild(background); TR("Close window when done expanding"), NULL);
rect.OffsetBy(11, 9); fLeaveDest = new BRadioButton("leaveDest",
rect.bottom -= 64; TR("Leave destination folder path empty"),
rect.right -= 22;
BBox *box = new BBox(rect, "background", B_FOLLOW_NONE,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
box->SetLabel("Expander settings");
background->AddChild(box);
float maxWidth = box->Bounds().right;
BRect frameRect = box->Bounds();
frameRect.OffsetBy(15, 23);
frameRect.right = frameRect.left + 200;
frameRect.bottom = frameRect.top + 20;
BRect textRect(frameRect);
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(1, 1);
BStringView *stringView = new BStringView(frameRect, "expansion", "Expansion:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fAutoExpand = new BCheckBox(frameRect, "autoExpand", "Automatically expand files", NULL);
fAutoExpand->ResizeToPreferred();
if (fAutoExpand->Frame().right > maxWidth)
maxWidth = fAutoExpand->Frame().right;
box->AddChild(fAutoExpand);
frameRect = fAutoExpand->Frame();
frameRect.top = fAutoExpand->Frame().bottom + 1;
fCloseWindow = new BCheckBox(frameRect, "closeWindowWhenDone", "Close window when done expanding", NULL);
fCloseWindow->ResizeToPreferred();
if (fCloseWindow->Frame().right > maxWidth)
maxWidth = fCloseWindow->Frame().right;
box->AddChild(fCloseWindow);
frameRect = stringView->Frame();
frameRect.top = fCloseWindow->Frame().bottom + 10;
stringView = new BStringView(frameRect, "destinationFolder", "Destination folder:",
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fLeaveDest = new BRadioButton(frameRect, "leaveDest", "Leave destination folder path empty",
new BMessage(MSG_LEAVEDEST)); new BMessage(MSG_LEAVEDEST));
fLeaveDest->ResizeToPreferred(); fSameDest = new BRadioButton("sameDir",
if (fLeaveDest->Frame().right > maxWidth) TR("Same directory as source (archive) file"),
maxWidth = fLeaveDest->Frame().right;
box->AddChild(fLeaveDest);
frameRect = fLeaveDest->Frame();
frameRect.top = fLeaveDest->Frame().bottom + 1;
fSameDest = new BRadioButton(frameRect, "sameDir", "Same directory as source (archive) file",
new BMessage(MSG_SAMEDIR)); new BMessage(MSG_SAMEDIR));
fSameDest->ResizeToPreferred(); fDestUse = new BRadioButton("destUse",
if (fSameDest->Frame().right > maxWidth) TR("Use:"), new BMessage(MSG_DESTUSE));
maxWidth = fSameDest->Frame().right; fDestText = new BTextControl("destText", "", "", new BMessage(MSG_DESTTEXT));
box->AddChild(fSameDest);
frameRect = fSameDest->Frame();
frameRect.top = frameRect.bottom + 1;
fDestUse = new BRadioButton(frameRect, "destUse", "Use:", new BMessage(MSG_DESTUSE));
fDestUse->ResizeToPreferred();
if (fDestUse->Frame().right > maxWidth)
maxWidth = fDestUse->Frame().right;
box->AddChild(fDestUse);
frameRect = fDestUse->Frame();
frameRect.left = fDestUse->Frame().right + 1;
frameRect.right = frameRect.left + 58;
frameRect.bottom = frameRect.top + 38;
fDestText = new BTextControl(frameRect, "destText", "", "", new BMessage(MSG_DESTTEXT));
box->AddChild(fDestText);
fDestText->ResizeToPreferred();
fDestText->SetDivider(0); fDestText->SetDivider(0);
fDestText->TextView()->MakeEditable(false); fDestText->TextView()->MakeEditable(false);
fDestText->ResizeTo(158, fDestText->Frame().Height());
fDestText->SetEnabled(false); fDestText->SetEnabled(false);
fSelect = new BButton("selectButton", TR("Select"),
frameRect = fDestText->Frame(); new BMessage(MSG_DESTSELECT));
frameRect.left = frameRect.right + 5;
fSelect = new BButton(frameRect, "selectButton", "Select", new BMessage(MSG_DESTSELECT));
fSelect->ResizeToPreferred();
if (fSelect->Frame().right > maxWidth)
maxWidth = fSelect->Frame().right;
box->AddChild(fSelect);
fSelect->SetEnabled(false); fSelect->SetEnabled(false);
fDestText->MoveBy(0, (fSelect->Frame().Height() - fDestText->Frame().Height()) / 2.0); fOpenDest = new BCheckBox("openDestination",
fDestText->ResizeTo(158, fDestText->Frame().Height()); TR("Open destination folder after extraction"), NULL);
fAutoShow = new BCheckBox("autoShow",
TR("Automatically show contents listing"), NULL);
frameRect = stringView->Frame(); BView* view = new BGroupView();
frameRect.top = fDestUse->Frame().bottom + 10; view->SetLayout(new BGroupLayout(B_HORIZONTAL));
view->AddChild(BGroupLayoutBuilder(B_VERTICAL)
.AddGroup(B_HORIZONTAL)
.Add(new BStringView("expansion", TR("Expansion:")))
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 1)
.Add(fAutoExpand)
.Add(fCloseWindow)
.SetInsets(10, 0, 0, 10)
.End()
.AddGroup(B_HORIZONTAL)
.Add(new BStringView("destinationFolder", TR("Destination folder:")))
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 1)
.Add(fLeaveDest)
.Add(fSameDest)
.Add(fDestUse)
.AddGroup(B_HORIZONTAL, 5)
.Add(fDestText, 0.8)
.Add(fSelect, 0.2)
.SetInsets(20, 0, 0, 0)
.End()
.SetInsets(10, 0, 0, 10)
.End()
.AddGroup(B_HORIZONTAL)
.Add(new BStringView("other", TR("Other:")))
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 1)
.Add(fOpenDest)
.Add(fAutoShow)
.SetInsets(10, 0, 0, 0)
.End()
.SetInsets(10, 10, 10, 10)
);
box->AddChild(view);
stringView = new BStringView(frameRect, "other", "Other:", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); BButton* button = new BButton("OKButton", TR("OK"), new BMessage(MSG_OK));
stringView->ResizeToPreferred();
if (stringView->Frame().right > maxWidth)
maxWidth = stringView->Frame().right;
box->AddChild(stringView);
frameRect.top = stringView->Frame().bottom + 5;
frameRect.left += 10;
fOpenDest = new BCheckBox(frameRect, "openDestination", "Open destination folder after extraction", NULL);
fOpenDest->ResizeToPreferred();
if (fOpenDest->Frame().right > maxWidth)
maxWidth = fOpenDest->Frame().right;
box->AddChild(fOpenDest);
frameRect = fOpenDest->Frame();
frameRect.top = frameRect.bottom + 1;
fAutoShow = new BCheckBox(frameRect, "autoShow", "Automatically show contents listing", NULL);
fAutoShow->ResizeToPreferred();
if (fAutoShow->Frame().right > maxWidth)
maxWidth = fAutoShow->Frame().right;
box->AddChild(fAutoShow);
box->ResizeTo(maxWidth + 15, fAutoShow->Frame().bottom + 10);
rect = BRect(Bounds().right - 89, Bounds().bottom - 40, Bounds().right - 14, Bounds().bottom - 16);
rect = Bounds();
BButton *button = new BButton(rect, "OKButton", "OK", new BMessage(MSG_OK));
button->MakeDefault(true); button->MakeDefault(true);
button->ResizeToPreferred(); BButton* cancel = new BButton("CancelButton", TR("Cancel"),
button->MoveTo(box->Frame().right - button->Frame().Width(), box->Frame().bottom + 10); new BMessage(MSG_CANCEL));
background->AddChild(button);
rect = button->Frame(); SetLayout(new BGroupLayout(B_HORIZONTAL));
BButton *cancel = new BButton(rect, "CancelButton", "Cancel", new BMessage(MSG_CANCEL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 11)
cancel->ResizeToPreferred(); .Add(box)
cancel->MoveBy(-cancel->Frame().Width() - 10, (button->Frame().Height() - cancel->Frame().Height()) / 2.0); .AddGroup(B_HORIZONTAL, 10)
background->AddChild(cancel); .AddGlue()
.Add(cancel)
.Add(button)
.End()
.SetInsets(10, 10, 10, 10)
);
ResizeTo(box->Frame().right + 11 , button->Frame().bottom + 11); CenterOnScreen();
BScreen screen(this);
MoveBy((screen.Frame().Width() - Bounds().Width()) / 2,
(screen.Frame().Height() - Bounds().Height()) / 2);
bool automatically_expand_files; bool automatically_expand_files;
bool close_when_done; bool close_when_done;
@ -239,7 +175,7 @@ ExpanderPreferences::~ExpanderPreferences()
void void
ExpanderPreferences::MessageReceived(BMessage *msg) ExpanderPreferences::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case MSG_DESTSELECT: case MSG_DESTSELECT:

View File

@ -15,12 +15,14 @@
#include <Application.h> #include <Application.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <GroupLayout.h> #include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
@ -42,10 +44,13 @@ const uint32 MSG_DESTTEXT = 'mDTX';
const uint32 MSG_SHOWCONTENTS = 'mSCT'; const uint32 MSG_SHOWCONTENTS = 'mSCT';
#undef TR_CONTEXT
#define TR_CONTEXT "ExpanderWindow"
ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref, ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
BMessage* settings) BMessage* settings)
: :
BWindow(frame, "Expander", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL), BWindow(frame, TR_CMT("Expander", "!! Window Title !!"), B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL),
fSourcePanel(NULL), fSourcePanel(NULL),
fDestPanel(NULL), fDestPanel(NULL),
fSourceChanged(true), fSourceChanged(true),
@ -61,9 +66,9 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
_AddMenuBar(layout); _AddMenuBar(layout);
fDestButton = new BButton("Destination", new BMessage(MSG_DEST)); fDestButton = new BButton(TR("Destination"), new BMessage(MSG_DEST));
fSourceButton = new BButton("Source", new BMessage(MSG_SOURCE)); fSourceButton = new BButton(TR("Source"), new BMessage(MSG_SOURCE));
fExpandButton = new BButton("Expand", new BMessage(MSG_EXPAND)); fExpandButton = new BButton(TR("Expand"), new BMessage(MSG_EXPAND));
BSize size = fDestButton->PreferredSize(); BSize size = fDestButton->PreferredSize();
size.width = max_c(size.width, fSourceButton->PreferredSize().width); size.width = max_c(size.width, fSourceButton->PreferredSize().width);
@ -98,7 +103,7 @@ ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref,
.Add(fDestText = new BTextControl(NULL, NULL, .Add(fDestText = new BTextControl(NULL, NULL,
new BMessage(MSG_DESTTEXT))) new BMessage(MSG_DESTTEXT)))
.AddGroup(B_HORIZONTAL, spacing) .AddGroup(B_HORIZONTAL, spacing)
.Add(fShowContents = new BCheckBox("Show contents", .Add(fShowContents = new BCheckBox(TR("Show contents"),
new BMessage(MSG_SHOWCONTENTS))) new BMessage(MSG_SHOWCONTENTS)))
.Add(fStatusView = new BStringView(NULL, NULL)) .Add(fStatusView = new BStringView(NULL, NULL))
.End() .End()
@ -139,19 +144,22 @@ ExpanderWindow::ValidateDest()
BEntry entry(fDestText->Text(), true); BEntry entry(fDestText->Text(), true);
BVolume volume; BVolume volume;
if (!entry.Exists()) { if (!entry.Exists()) {
BAlert* alert = new BAlert("destAlert", "The destination" BAlert* alert = new BAlert("destAlert",
" folder does not exist.", "Cancel", NULL, NULL, TR("The destination folder does not exist."),
TR("Cancel"), NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go(); alert->Go();
return false; return false;
} else if (!entry.IsDirectory()) { } else if (!entry.IsDirectory()) {
(new BAlert("destAlert", "The destination" (new BAlert("destAlert",
" is not a folder.", "Cancel", NULL, NULL, TR("The destination is not a folder."),
TR("Cancel"), NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT))->Go(); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT))->Go();
return false; return false;
} else if (entry.GetVolume(&volume) != B_OK || volume.IsReadOnly()) { } else if (entry.GetVolume(&volume) != B_OK || volume.IsReadOnly()) {
(new BAlert("destAlert", "The destination is read only.", (new BAlert("destAlert",
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, TR("The destination is read only."),
TR("Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING,
B_WARNING_ALERT))->Go(); B_WARNING_ALERT))->Go();
return false; return false;
} else { } else {
@ -175,6 +183,7 @@ ExpanderWindow::MessageReceived(BMessage* msg)
BMessenger messenger(this); BMessenger messenger(this);
fSourcePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &srcRef, fSourcePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &srcRef,
B_FILE_NODE, false, NULL, new RuleRefFilter(fRules), true); B_FILE_NODE, false, NULL, new RuleRefFilter(fRules), true);
(fSourcePanel->Window())->SetTitle(TR("Expander: Open"));
} else } else
fSourcePanel->SetPanelDirectory(&srcRef); fSourcePanel->SetPanelDirectory(&srcRef);
fSourcePanel->Show(); fSourcePanel->Show();
@ -226,9 +235,9 @@ ExpanderWindow::MessageReceived(BMessage* msg)
case MSG_STOP: case MSG_STOP:
if (fExpandingStarted) { if (fExpandingStarted) {
fExpandingThread->SuspendExternalExpander(); fExpandingThread->SuspendExternalExpander();
BAlert* alert = new BAlert("stopAlert", "Are you sure you want " BAlert* alert = new BAlert("stopAlert",
"to stop expanding this\narchive? The expanded items may " TR("Are you sure you want to stop expanding this\narchive? The expanded items may not be complete."),
"not be complete.", "Stop", "Continue", NULL, TR("Stop"), TR("Continue"), NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
if (alert->Go() == 0) { if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander(); fExpandingThread->ResumeExternalExpander();
@ -245,7 +254,7 @@ ExpanderWindow::MessageReceived(BMessage* msg)
case MSG_SHOWCONTENTS: case MSG_SHOWCONTENTS:
// change menu item label // change menu item label
fShowItem->SetLabel(fShowContents->Value() == B_CONTROL_OFF fShowItem->SetLabel(fShowContents->Value() == B_CONTROL_OFF
? "Show contents" : "Hide contents"); ? TR("Show contents") : TR("Hide contents"));
if (fShowContents->Value() == B_CONTROL_OFF) { if (fShowContents->Value() == B_CONTROL_OFF) {
if (fListingStarted) if (fListingStarted)
@ -260,8 +269,8 @@ ExpanderWindow::MessageReceived(BMessage* msg)
{ {
BEntry entry(fSourceText->Text(), true); BEntry entry(fSourceText->Text(), true);
if (!entry.Exists()) { if (!entry.Exists()) {
BAlert* alert = new BAlert("srcAlert", "The file doesn't exist", BAlert* alert = new BAlert("srcAlert", TR("The file doesn't exist"),
"Cancel", NULL, NULL, TR("Cancel"), NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go(); alert->Go();
break; break;
@ -282,8 +291,8 @@ ExpanderWindow::MessageReceived(BMessage* msg)
BString string = "The file : "; BString string = "The file : ";
string += fSourceText->Text(); string += fSourceText->Text();
string += " is not supported"; string += TR_MARK(" is not supported");
BAlert* alert = new BAlert("srcAlert", string.String(), "Cancel", BAlert* alert = new BAlert("srcAlert", string.String(), TR("Cancel"),
NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT); NULL, NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_INFO_ALERT);
alert->Go(); alert->Go();
@ -324,7 +333,7 @@ ExpanderWindow::MessageReceived(BMessage* msg)
// thread has finished (finished, quit, killed, we don't know) // thread has finished (finished, quit, killed, we don't know)
// reset window state // reset window state
if (fExpandingStarted) { if (fExpandingStarted) {
fStatusView->SetText("File expanded"); fStatusView->SetText(TR("File expanded"));
StopExpanding(); StopExpanding();
OpenDestFolder(); OpenDestFolder();
CloseWindowOrKeepOpen(); CloseWindowOrKeepOpen();
@ -339,7 +348,7 @@ ExpanderWindow::MessageReceived(BMessage* msg)
case 'exrr': // thread has finished case 'exrr': // thread has finished
// reset window state // reset window state
fStatusView->SetText("Error when expanding archive"); fStatusView->SetText(TR("Error when expanding archive"));
CloseWindowOrKeepOpen(); CloseWindowOrKeepOpen();
break; break;
@ -359,9 +368,9 @@ ExpanderWindow::CanQuit()
if (fExpandingStarted) { if (fExpandingStarted) {
fExpandingThread->SuspendExternalExpander(); fExpandingThread->SuspendExternalExpander();
BAlert* alert = new BAlert("stopAlert", "Are you sure you want to stop " BAlert* alert = new BAlert("stopAlert",
"expanding this\narchive? The expanded items may not be complete.", TR("Are you sure you want to stop expanding this\narchive? The expanded items may not be complete."),
"Stop", "Continue", NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING, TR("Stop"), TR("Continue"), NULL, B_WIDTH_AS_USUAL, B_EVEN_SPACING,
B_WARNING_ALERT); B_WARNING_ALERT);
if (alert->Go() == 0) { if (alert->Go() == 0) {
fExpandingThread->ResumeExternalExpander(); fExpandingThread->ResumeExternalExpander();
@ -446,42 +455,50 @@ ExpanderWindow::RefsReceived(BMessage* msg)
} }
} }
#undef TR_CONTEXT
#define TR_CONTEXT "ExpanderMenu"
void void
ExpanderWindow::_AddMenuBar(BLayout* layout) ExpanderWindow::_AddMenuBar(BLayout* layout)
{ {
fBar = new BMenuBar("menu_bar", B_ITEMS_IN_ROW, B_INVALIDATE_AFTER_LAYOUT); fBar = new BMenuBar("menu_bar", B_ITEMS_IN_ROW, B_INVALIDATE_AFTER_LAYOUT);
BMenu* menu = new BMenu("File"); BMenu* menu = new BMenu(TR("File"));
BMenuItem* item; BMenuItem* item;
menu->AddItem(item = new BMenuItem("About Expander" B_UTF8_ELLIPSIS, menu->AddItem(item = new BMenuItem(TR("About Expander…"),
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
item->SetTarget(be_app_messenger); item->SetTarget(be_app_messenger);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(fSourceItem = new BMenuItem("Set source" B_UTF8_ELLIPSIS, menu->AddItem(fSourceItem = new BMenuItem(TR("Set source…"),
new BMessage(MSG_SOURCE), 'O')); new BMessage(MSG_SOURCE), 'O'));
menu->AddItem(fDestItem = new BMenuItem("Set destination" B_UTF8_ELLIPSIS, menu->AddItem(fDestItem = new BMenuItem(TR("Set destination…"),
new BMessage(MSG_DEST), 'D')); new BMessage(MSG_DEST), 'D'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(fExpandItem = new BMenuItem("Expand", new BMessage(MSG_EXPAND), menu->AddItem(fExpandItem = new BMenuItem(TR("Expand"),
'E')); new BMessage(MSG_EXPAND), 'E'));
fExpandItem->SetEnabled(false); fExpandItem->SetEnabled(false);
menu->AddItem(fShowItem = new BMenuItem("Show contents", menu->AddItem(fShowItem = new BMenuItem(TR("Show contents"),
new BMessage(MSG_SHOW), 'L')); new BMessage(MSG_SHOW), 'L'));
fShowItem->SetEnabled(false); fShowItem->SetEnabled(false);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(fStopItem = new BMenuItem("Stop", new BMessage(MSG_STOP), 'K')); menu->AddItem(fStopItem = new BMenuItem(TR("Stop"),
new BMessage(MSG_STOP), 'K'));
fStopItem->SetEnabled(false); fStopItem->SetEnabled(false);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W')); menu->AddItem(new BMenuItem(TR("Close"), new BMessage(B_QUIT_REQUESTED), 'W'));
fBar->AddItem(menu); fBar->AddItem(menu);
menu = new BMenu("Settings"); menu = new BMenu(TR("Settings"));
menu->AddItem(fPreferencesItem = new BMenuItem("Settings" B_UTF8_ELLIPSIS, menu->AddItem(fPreferencesItem = new BMenuItem(TR("Settings…"),
new BMessage(MSG_PREFERENCES), 'S')); new BMessage(MSG_PREFERENCES), 'S'));
fBar->AddItem(menu); fBar->AddItem(menu);
layout->AddView(fBar); layout->AddView(fBar);
} }
#undef TR_CONTEXT
#define TR_CONTEXT "ExpanderWindow"
void void
ExpanderWindow::StartExpanding() ExpanderWindow::StartExpanding()
{ {
@ -491,8 +508,9 @@ ExpanderWindow::StartExpanding()
BEntry destEntry(fDestText->Text(), true); BEntry destEntry(fDestText->Text(), true);
if (!destEntry.Exists()) { if (!destEntry.Exists()) {
BAlert* alert = new BAlert("destAlert", "The folder was either moved, " BAlert* alert = new BAlert("destAlert",
"renamed or not\nsupported.", "Cancel", NULL, NULL, TR("The folder was either moved, renamed or not\nsupported."),
TR("Cancel"), NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go(); alert->Go();
return; return;
@ -503,7 +521,7 @@ ExpanderWindow::StartExpanding()
message.AddRef("srcRef", &fSourceRef); message.AddRef("srcRef", &fSourceRef);
message.AddRef("destRef", &fDestRef); message.AddRef("destRef", &fDestRef);
fExpandButton->SetLabel("Stop"); fExpandButton->SetLabel(TR("Stop"));
fSourceButton->SetEnabled(false); fSourceButton->SetEnabled(false);
fDestButton->SetEnabled(false); fDestButton->SetEnabled(false);
fShowContents->SetEnabled(false); fShowContents->SetEnabled(false);
@ -516,7 +534,7 @@ ExpanderWindow::StartExpanding()
BEntry entry(&fSourceRef); BEntry entry(&fSourceRef);
BPath path(&entry); BPath path(&entry);
BString text("Expanding file "); BString text(TR("Expanding file "));
text.Append(path.Leaf()); text.Append(path.Leaf());
fStatusView->SetText(text.String()); fStatusView->SetText(text.String());
@ -537,7 +555,7 @@ ExpanderWindow::StopExpanding(void)
fExpandingStarted = false; fExpandingStarted = false;
fExpandButton->SetLabel("Expand"); fExpandButton->SetLabel(TR("Expand"));
fSourceButton->SetEnabled(true); fSourceButton->SetEnabled(true);
fDestButton->SetEnabled(true); fDestButton->SetEnabled(true);
fShowContents->SetEnabled(true); fShowContents->SetEnabled(true);
@ -642,7 +660,7 @@ ExpanderWindow::StartListing()
fDestItem->SetEnabled(false); fDestItem->SetEnabled(false);
fExpandItem->SetEnabled(false); fExpandItem->SetEnabled(false);
fShowItem->SetEnabled(true); fShowItem->SetEnabled(true);
fShowItem->SetLabel("Hide contents"); fShowItem->SetLabel(TR("Hide contents"));
fStopItem->SetEnabled(false); fStopItem->SetEnabled(false);
fPreferencesItem->SetEnabled(false); fPreferencesItem->SetEnabled(false);
@ -652,7 +670,7 @@ ExpanderWindow::StartListing()
BEntry entry(&fSourceRef); BEntry entry(&fSourceRef);
BPath path(&entry); BPath path(&entry);
BString text("Creating listing for "); BString text(TR("Creating listing for "));
text.Append(path.Leaf()); text.Append(path.Leaf());
fStatusView->SetText(text.String()); fStatusView->SetText(text.String());
fListingText->SetText(""); fListingText->SetText("");

View File

@ -1,7 +1,5 @@
SubDir HAIKU_TOP src apps expander ; SubDir HAIKU_TOP src apps expander ;
SetSubDirSupportedPlatformsBeOSCompatible ;
Application Expander : Application Expander :
ExpanderApp.cpp ExpanderApp.cpp
ExpanderWindow.cpp ExpanderWindow.cpp
@ -11,7 +9,17 @@ Application Expander :
ExpanderPreferences.cpp ExpanderPreferences.cpp
DirectoryFilePanel.cpp DirectoryFilePanel.cpp
ExpanderRules.cpp ExpanderRules.cpp
: be tracker $(TARGET_LIBSUPC++) : be tracker liblocale.so $(TARGET_LIBSUPC++)
: Expander.rdef : Expander.rdef
; ;
DoCatalogs Expander :
x-vnd.Haiku-Expander
:
ExpanderApp.cpp
ExpanderWindow.cpp
ExpanderSettings.cpp
DirectoryFilePanel.cpp
: en.catalog
:
;