diff --git a/Assets/Screenshots/CommandSelectWindow.png b/Assets/Screenshots/CommandSelectWindow.png index d59af6a..de9f0f6 100644 Binary files a/Assets/Screenshots/CommandSelectWindow.png and b/Assets/Screenshots/CommandSelectWindow.png differ diff --git a/Assets/Screenshots/TrackRunnerCommands.png b/Assets/Screenshots/TrackRunnerCommands.png index fd77d78..39edd0f 100644 Binary files a/Assets/Screenshots/TrackRunnerCommands.png and b/Assets/Screenshots/TrackRunnerCommands.png differ diff --git a/Assets/Screenshots/TrackRunnerIconMenu.png b/Assets/Screenshots/TrackRunnerIconMenu.png index cca1a75..e3fb5e8 100644 Binary files a/Assets/Screenshots/TrackRunnerIconMenu.png and b/Assets/Screenshots/TrackRunnerIconMenu.png differ diff --git a/Assets/Screenshots/TrackRunnerIconPrefs.png b/Assets/Screenshots/TrackRunnerIconPrefs.png index 8d49e49..ece05b6 100644 Binary files a/Assets/Screenshots/TrackRunnerIconPrefs.png and b/Assets/Screenshots/TrackRunnerIconPrefs.png differ diff --git a/Assets/Screenshots/TrackRunnerMenu.png b/Assets/Screenshots/TrackRunnerMenu.png index 10da85d..d736324 100644 Binary files a/Assets/Screenshots/TrackRunnerMenu.png and b/Assets/Screenshots/TrackRunnerMenu.png differ diff --git a/Assets/Screenshots/TrackRunnerPrefs.png b/Assets/Screenshots/TrackRunnerPrefs.png index d5cfa8b..df42219 100644 Binary files a/Assets/Screenshots/TrackRunnerPrefs.png and b/Assets/Screenshots/TrackRunnerPrefs.png differ diff --git a/Assets/UserGuide/index.rst b/Assets/UserGuide/index.rst index e3b819e..2c61d92 100644 --- a/Assets/UserGuide/index.rst +++ b/Assets/UserGuide/index.rst @@ -60,6 +60,8 @@ Command Management Window The command management window allows you to add/edit/remove/sort shortcuts. +You can drag'n'drop a script to replace the currently shown command path. +If the command is a script, the `Show in Tracker` button will open its location in a Tracker window. From there you can rename it or open it in an editor etc. Command List diff --git a/Source/CommandsWindow.cpp b/Source/CommandsWindow.cpp index cc9b0e8..bc8eb45 100644 --- a/Source/CommandsWindow.cpp +++ b/Source/CommandsWindow.cpp @@ -17,8 +17,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -32,6 +34,7 @@ enum { kUserGuideAction = 'GiDe', kListSelectAction = 'LsTs', kBrowseCommandAction = 'BrWz', + kShowCommandAction = 'SwWz', kListUpdateAction = 'LsUp' }; @@ -81,6 +84,7 @@ CommandsWindow::CommandsWindow(BString& title) .SetInsets(0) .Add(fBrowseButton = new BButton("Browse" B_UTF8_ELLIPSIS, new BMessage(kBrowseCommandAction))) .AddGlue() + .Add(fShowButton = new BButton("Show in Tracker", new BMessage(kShowCommandAction))) .End() .Add(fTerminalCheckBox, 1, 3) .End() @@ -121,6 +125,9 @@ CommandsWindow::MessageReceived(BMessage* message) case kBrowseCommandAction: _BrowseCommand(); break; + case kShowCommandAction: + _ShowCommand(); + break; case kDeleteCommandAction: _DeleteCommand(); break; @@ -173,6 +180,73 @@ CommandsWindow::_BrowseCommand() } +void +CommandsWindow::_ShowCommand() +{ + BEntry itemEntry(_Deescape(fCommandControl->Text())); + status_t status = itemEntry.InitCheck(); + if (status == B_OK) { + BEntry parentDirectory; + status = itemEntry.GetParent(&parentDirectory); + if (status == B_OK) { + entry_ref ref; + status = parentDirectory.GetRef(&ref); + if (status == B_OK) { + node_ref nref; + status = itemEntry.GetNodeRef(&nref); + if (status == B_OK) + _ShowInTracker(ref, &nref); + } + } + } +} + + +status_t +CommandsWindow::_ShowInTracker(const entry_ref& ref, const node_ref* nref) +{ + status_t status = B_ERROR; + + BMessenger tracker("application/x-vnd.Be-TRAK"); + if (tracker.IsValid()) { + BMessage message(B_REFS_RECEIVED); + message.AddRef("refs", &ref); + + if (nref != NULL) + message.AddData("nodeRefToSelect", B_RAW_TYPE, (void*)nref, sizeof(node_ref)); + + status = tracker.SendMessage(&message); + } + return status; +} + + +bool +CommandsWindow::_CommandIsScript() +{ + BPath path = _Deescape(fCommandControl->Text()); + if (path.InitCheck() != B_OK) + return false; + + char mimeType[B_MIME_TYPE_LENGTH]; + BNode commandNode(path.Path()); + BNodeInfo(&commandNode).GetType(mimeType); + if (strncmp("text/", mimeType, 5) == 0) + return true; + + return false; +} + + +const char* +CommandsWindow::_Deescape(const char* path) +{ + BString text(path); + text.CharacterDeescape('\\'); + return text.String(); +} + + void CommandsWindow::_InitNewCommand() { @@ -230,6 +304,7 @@ CommandsWindow::_SelectItem() fCommandControl->SetEnabled(true); fBrowseButton->SetEnabled(true); + fShowButton->SetEnabled(true); fTerminalCheckBox->SetValue(item->UseTerminal()); fTerminalCheckBox->SetEnabled(true); @@ -252,6 +327,8 @@ CommandsWindow::_UpdateItem() fListView->InvalidateItem(fListView->CurrentSelection()); } + fShowButton->SetEnabled(_CommandIsScript()); + _SaveCommands(); } @@ -319,6 +396,7 @@ CommandsWindow::_InitControls() fCommandControl->SetEnabled(false); fBrowseButton->SetEnabled(false); + fShowButton->SetEnabled(false); fTerminalCheckBox->SetValue(1); fTerminalCheckBox->SetEnabled(false); diff --git a/Source/CommandsWindow.h b/Source/CommandsWindow.h index b49767a..6750d8d 100644 --- a/Source/CommandsWindow.h +++ b/Source/CommandsWindow.h @@ -33,12 +33,17 @@ class CommandsWindow : public BWindow { void _SelectItem(); void _UpdateItem(); void _BrowseCommand(); + void _ShowCommand(); + status_t _ShowInTracker(const entry_ref& ref, const node_ref* nref = NULL); + bool _CommandIsScript(); + const char* _Deescape(const char* path); void _RefsReceived(BMessage* message); status_t _LoadCommands(); status_t _SaveCommands(); BBitmap* _ResourceBitmap(const char* name, float width, float height); BButton* fBrowseButton; + BButton* fShowButton; BCheckBox* fTerminalCheckBox; BListView* fListView; BFilePanel* fBrowsePanel;