Factor out a ValidateDest() function that checks if the destination is valid

and throws up a BAlert if not. Reuse this when the user clicks expand to check
for and grab the destination path. This fixes the problem that if the user
manually types in or pastes a destination path and then immediately clicks
Expand, the actual destination path used is never updated. Thanks to Daniel
Teixeira for reporting.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28283 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2008-10-22 13:54:30 +00:00
parent 4932bc5ea8
commit 950eeadd92
2 changed files with 19 additions and 10 deletions
+18 -10
View File
@@ -179,6 +179,21 @@ ExpanderWindow::~ExpanderWindow()
delete fSourcePanel;
}
bool
ExpanderWindow::ValidateDest()
{
BEntry entry(fDestText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("destAlert", "The destination"
" directory does not exist.", "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go();
return false;
} else {
entry.GetRef(&fDestRef);
return true;
}
}
void
ExpanderWindow::FrameResized(float width, float height)
@@ -233,6 +248,8 @@ ExpanderWindow::MessageReceived(BMessage *msg)
break;
case MSG_EXPAND:
if (!ValidateDest())
break;
if (!fExpandingStarted) {
StartExpanding();
break;
@@ -309,16 +326,7 @@ ExpanderWindow::MessageReceived(BMessage *msg)
break;
case MSG_DESTTEXT:
{
BEntry entry(fDestText->Text(), true);
if (!entry.Exists()) {
BAlert *alert = new BAlert("destAlert", "The directory was either moved, renamed or not\n"
"supported.",
"Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_WARNING_ALERT);
alert->Go();
break;
}
entry.GetRef(&fDestRef);
ValidateDest();
}
break;
case MSG_PREFERENCES:
+1
View File
@@ -49,6 +49,7 @@ class ExpanderWindow : public BWindow {
void _UpdateWindowSize(bool showContents);
void StartListing();
void StopListing();
bool ValidateDest();
BFilePanel *fSourcePanel;
DirectoryFilePanel *fDestPanel;