Setting the escape key as shortcut for the Cancel options of Tracker's dialogs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29958 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström 2009-04-05 23:47:58 +00:00
parent 0f617d4476
commit 019f90e634
10 changed files with 179 additions and 80 deletions

View File

@ -232,6 +232,7 @@ AutoMounter::_SuggestMountFlags(const BPartition* partition,
BAlert* alert = new BAlert("Mount Warning", string.String(),
"Mount Read/Write", "Cancel", "Mount Read-only",
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE);
int32 choice = alert->Go();
switch (choice) {
case 0:
@ -284,8 +285,10 @@ AutoMounter::_SuggestForceUnmount(const char* name, status_t error)
"Note: if an application is currently writing to the volume, unmounting"
" it now might result in loss of data.\n";
int32 choice = (new BAlert("", text.String(), "Cancel", "Force Unmount",
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert* alert = new BAlert("", text.String(), "Cancel", "Force Unmount",
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
int32 choice = alert->Go();
return choice == 1;
}
@ -1018,8 +1021,10 @@ UnmountIfMatchingID(Partition *partition, void *castToParams)
text << "To unmount " << partition->VolumeName() << " some query "
"windows have to be closed. Would you like to close the query "
"windows?";
if ((new BAlert("", text.String(), "Cancel", "Close and unmount", NULL,
B_WIDTH_FROM_LABEL))->Go() == 0)
BAlert* alert = new BAlert("", text.String(), "Cancel",
"Close and unmount", NULL, B_WIDTH_FROM_LABEL);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0)
return partition;
tracker->CloseActiveQueryWindows(params->device);
}

View File

@ -2973,8 +2973,10 @@ BContainerWindow::LoadAddOn(BMessage *message)
if (result != B_OK) {
char buffer[1024];
sprintf(buffer, "Error %s loading Add-On %s.", strerror(result), addonRef.name);
(new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert* alert = new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return;
}

View File

@ -462,8 +462,10 @@ FSClipboardPaste(Model *model, uint32 linksMode)
// can't copy/paste to root('/') directory
if (model->IsRoot()) {
(new BAlert("", kNoCopyToRootStr, "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoCopyToRootStr, "Cancel",
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
okToMove = false;
}
@ -472,8 +474,10 @@ FSClipboardPaste(Model *model, uint32 linksMode)
// can't copy items into the trash
if (copyList->CountItems() > 0 && FSIsTrashDir(&entry)) {
(new BAlert("", kNoCopyToTrashStr, "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoCopyToTrashStr, "Cancel",
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
okToMove = false;
}

View File

@ -180,12 +180,17 @@ TrackerCopyLoopControl::FileError(const char *message, const char *name,
char buffer[512];
sprintf(buffer, message, name, strerror(error));
if (allowContinue)
return (new BAlert("", buffer, "Cancel", "OK", 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0;
if (allowContinue) {
BAlert *alert = new BAlert("", buffer, "Cancel", "OK", 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE);
return alert->Go() != 0;
}
(new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
BAlert *alert = new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return false;
}
@ -546,8 +551,11 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
if (gStatusWindow)
gStatusWindow->RemoveStatusItem(thread);
(new BAlert("", "You can't move or copy items to read-only volumes.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("",
"You can't move or copy items to read-only volumes.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return B_ERROR;
}
@ -565,8 +573,10 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
else
errorStr = "You cannot copy or move the root directory.";
(new BAlert("", errorStr, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", errorStr, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return B_ERROR;
}
if (moveMode == kMoveSelectionTo
@ -604,8 +614,10 @@ InitCopy(uint32 moveMode, BObjectList<entry_ref> *srcList, thread_id thread,
// check for free space before starting copy
if ((totalSize + (4 * kKBSize)) >= dstVol->FreeBytes()) {
(new BAlert("", kNoFreeSpace, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoFreeSpace, "Cancel",
0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return B_ERROR;
}
}
@ -766,8 +778,10 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList, u
if (sourceEntry.InitCheck() != B_OK) {
BString error;
error << "Error moving \"" << srcRef->name << "\".";
(new BAlert("", error.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", error.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
break;
}
@ -781,8 +795,10 @@ MoveTask(BObjectList<entry_ref> *srcList, BEntry *destEntry, BList *pointList, u
BString error;
error << "Error moving \"" << srcRef->name << "\" to Trash. ("
<< strerror(result) << ")";
(new BAlert("", error.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", error.String(), "Cancel",
0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
break;
}
continue;
@ -1619,8 +1635,10 @@ MoveEntryToTrash(BEntry *entry, BPoint *loc, Undo &undo)
volume.GetName(name);
char buffer[256];
sprintf(buffer, "Cannot unmount the boot volume \"%s\".", name);
(new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", buffer, "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
} else {
BMessage message(kUnmountVolume);
message.AddInt32("device_id", volume.Device());
@ -1723,8 +1741,11 @@ PreFlightNameCheck(BObjectList<entry_ref> *srcList, const BDirectory *destDir,
const char *verb = (moveMode == kMoveSelectionTo) ? "moving" : "copying";
char replaceMsg[256];
sprintf(replaceMsg, kReplaceManyStr, verb, verb);
switch ((new BAlert("", replaceMsg, "Cancel", "Prompt", "Replace All"))->Go()) {
BAlert *alert = new BAlert("", replaceMsg,
"Cancel", "Prompt", "Replace All");
alert->SetShortcut(0, B_ESCAPE);
switch (alert->Go()) {
case 0:
return kCanceled;
@ -1857,11 +1878,12 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
// special case single collision (don't need Replace All shortcut)
BAlert *alert;
if (multipleCollisions || sourceIsDirectory)
if (multipleCollisions || sourceIsDirectory) {
alert = new BAlert("", replaceMsg, "Skip", "Replace All");
else
} else {
alert = new BAlert("", replaceMsg, "Cancel", "Replace");
alert->SetShortcut(0, B_ESCAPE);
}
switch (alert->Go()) {
case 0: // user selected "Cancel" or "Skip"
replaceAll = kCanceled;
@ -1887,8 +1909,10 @@ CheckName(uint32 moveMode, const BEntry *sourceEntry, const BDirectory *destDir,
BString error;
error << "There was a problem trying to replace \""
<< name << "\". The item might be open or busy.";
(new BAlert("", error.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", error.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
return err;
@ -2769,8 +2793,10 @@ FSCreateNewFolderIn(const node_ref *dirNode, entry_ref *newRef,
}
}
(new BAlert("", "Sorry, could not create a new folder.", "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", "Sorry, could not create a new folder.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return result;
}
@ -2914,12 +2940,17 @@ _TrackerLaunchAppWithDocuments(const entry_ref *appRef, const BMessage *refs, bo
alertString << "Could not open \"" << appRef->name << "\" (" << strerror(error) << "). ";
if (refs && openWithOK) {
alertString << kFindAlternativeStr;
if ((new BAlert("", alertString.String(), "Cancel", "Find", 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 1)
BAlert *alert = new BAlert("", alertString.String(),
"Cancel", "Find", 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 1)
error = TrackerOpenWith(refs);
} else
(new BAlert("", alertString.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
} else {
BAlert *alert = new BAlert("", alertString.String(),
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
}
}
@ -3131,8 +3162,11 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
// offer the possibility to change the permissions
alertString << "\nShould this be fixed?";
if ((new BAlert("", alertString.String(), "Cancel", "Proceed", 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 1) {
BAlert *alert = new BAlert("", alertString.String(),
"Cancel", "Proceed", 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 1) {
BEntry entry(&documentRef);
mode_t permissions;
@ -3185,12 +3219,18 @@ _TrackerLaunchDocuments(const entry_ref */*doNotUse*/, const BMessage *refs,
if (openWithOK) {
ASSERT(alternative);
alertString << alternative;
if ((new BAlert("", alertString.String(), "Cancel", "Find", 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 1)
BAlert *alert = new BAlert("", alertString.String(),
"Cancel", "Find", 0, B_WIDTH_AS_USUAL,
B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 1)
error = TrackerOpenWith(refs);
} else
(new BAlert("", alertString.String(), "Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
} else {
BAlert *alert = new BAlert("", alertString.String(),
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
}
}

View File

@ -2236,8 +2236,12 @@ NameItemPanel::MessageReceived(BMessage *message)
{
const char *text = fNameFld->Text();
if (!text || text[0] == '\0'){
if ((new BAlert("", "The new name is empty, please enter a name",
"Cancel", "OK", NULL, B_WIDTH_AS_USUAL))->Go() == 0)
BAlert *alert = new BAlert("",
"The new name is empty, please "
"enter a name", "Cancel", "OK", NULL,
B_WIDTH_AS_USUAL);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0)
return;
}
BMessage nameChangeMessage(kNameChange);

View File

@ -1389,6 +1389,16 @@ TFilePanel::ShowCenteredAlert(const char *text, const char *button1,
BAlert *alert = new BAlert("", text, button1, button2, button3,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->MoveTo(Frame().left + 10, Frame().top + 10);
if (strncmp(button1, "Cancel", 7))
alert->SetShortcut(0, B_ESCAPE);
if (strncmp(button2, "Cancel", 7))
alert->SetShortcut(1, B_ESCAPE);
if (strncmp(button3, "Cancel", 7))
alert->SetShortcut(2, B_ESCAPE);
return alert->Go();
}

View File

@ -678,8 +678,10 @@ OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
"publisher of the application and ask them to update their application "
"to list the type of your document as supported.";
if ((new BAlert("", warning.String(), "Cancel", "Open", 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 0)
BAlert *alert = new BAlert("", warning.String(),
"Cancel", "Open", 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0)
return;
}
// else - once we have an extensible sniffer, tell users to ask

View File

@ -2392,9 +2392,14 @@ BPoseView::RemoveColumn(BColumn *columnToRemove, bool runAlert)
{
// make sure last column is not removed
if (CountColumns() == 1) {
if (runAlert)
(new BAlert("", "You must have at least one Attribute showing.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
if (runAlert) {
BAlert *alert = new BAlert("",
"You must have at least one Attribute showing.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
}
return false;
}
@ -4491,22 +4496,28 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
bool okToMove = true;
if (destFolder->IsRoot()) {
(new BAlert("", kNoCopyToRootStr, "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoCopyToRootStr, "Cancel",
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
okToMove = false;
}
// can't copy items into the trash
if (forceCopy && destIsTrash) {
(new BAlert("", kNoCopyToTrashStr, "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoCopyToTrashStr, "Cancel",
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
okToMove = false;
}
// can't create symlinks into the trash
if (createLink && destIsTrash) {
(new BAlert("", kNoLinkToTrashStr, "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", kNoLinkToTrashStr, "Cancel",
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
okToMove = false;
}
@ -4514,8 +4525,10 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
if (srcWindow->TargetModel()->IsQuery()
&& !forceCopy && !destIsTrash && !createLink) {
srcWindow->UpdateIfNeeded();
okToMove = (new BAlert("", kOkToMoveStr, "Cancel", "Move", NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 1;
BAlert *alert = new BAlert("", kOkToMoveStr, "Cancel",
"Move", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
okToMove = alert->Go() == 1;
}
if (okToMove) {
@ -5377,9 +5390,10 @@ CheckVolumeReadOnly(const entry_ref *ref)
{
BVolume volume (ref->device);
if (volume.IsReadOnly()) {
BAlert *alert (new BAlert ("", "Files cannot be moved or deleted "
"from a read-only volume.", "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT));
BAlert *alert = new BAlert ("", "Files cannot be moved or "
"deleted from a read-only volume.", "Cancel", NULL,
NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return false;
}
@ -5427,7 +5441,9 @@ BPoseView::MoveSelectionOrEntryToTrash(const entry_ref *ref, bool selectNext)
"be reverted.)";
}
if ((new BAlert("", alertText, "Cancel", "Delete"))->Go() == 0)
BAlert *alert = new BAlert("", alertText, "Cancel", "Delete");
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0)
return;
}
@ -7644,8 +7660,11 @@ BPoseView::OpenInfoWindows()
{
BMessenger tracker(kTrackerSignature);
if (!tracker.IsValid()) {
(new BAlert("", "The Tracker must be running to see Info windows.",
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", "The Tracker must be running "
"to see Info windows.", "Cancel", NULL, NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return;
}
SendSelectionAsRefs(kGetInfo);
@ -7657,8 +7676,11 @@ BPoseView::SetDefaultPrinter()
{
BMessenger tracker(kTrackerSignature);
if (!tracker.IsValid()) {
(new BAlert("", "The Tracker must be running to see set the default printer.",
"Cancel", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("", "The Tracker must be running "
"to see set the default printer.", "Cancel", NULL,
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return;
}
SendSelectionAsRefs(kMakeActivePrinter);

View File

@ -680,9 +680,11 @@ TTracker::OpenRef(const entry_ref *ref, const node_ref *nodeToClose,
if (!brokenLinkWithSpecificHandler) {
delete model;
(new BAlert("", "There was an error resolving the link.",
"Cancel", 0, 0,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("",
"There was an error resolving the link.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return result;
}
} else

View File

@ -1602,8 +1602,10 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
&& type != B_DOUBLE_TYPE
&& type != B_CHAR_TYPE
&& type != B_BOOL_TYPE) {
(new BAlert("", "Sorry, you cannot edit that attribute.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
BAlert *alert = new BAlert("", "Sorry, you cannot edit that attribute.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return false;
}
@ -1634,8 +1636,11 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
sscanf(textView->Text(), "%c", &ch);
//Check if we read the start of a multi-byte glyph:
if (!isprint(ch)) {
(new BAlert("", "Sorry, The 'Character' attribute cannot store a multi-byte glyph.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
BAlert *alert = new BAlert("", "Sorry, The 'Character' "
"attribute cannot store a multi-byte glyph.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->Go();
return false;
}
@ -1732,8 +1737,11 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
}
if (size < 0) {
(new BAlert("", "There was an error writing the attribute.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
BAlert *alert = new BAlert("",
"There was an error writing the attribute.",
"Cancel", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_CANCEL);
alert->Go();
fValueIsDefined = false;
return false;