TextSearch: add option to set target to parent directory
Two usage scenarios: * Wrong directory selected when invoking as Tracker add-on. I often find myself having TextSearch invoked on selected child, when I wanted it to open in parent context. * Result was not found in target directory, so maybe the search should be broader. Change-Id: I2621f3cec7459572ddae438de4ba42ce74432e28 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3044 Reviewed-by: humdinger <humdingerb@gmail.com>
This commit is contained in:
parent
5b80a2fa0d
commit
2775737e9d
@ -127,6 +127,7 @@ GrepWindow::GrepWindow(BMessage* message)
|
||||
|
||||
_SetWindowTitle();
|
||||
_CreateMenus();
|
||||
_UpdateMenus();
|
||||
_CreateViews();
|
||||
_LayoutViews();
|
||||
_LoadPrefs();
|
||||
@ -194,6 +195,10 @@ void GrepWindow::MessageReceived(BMessage* message)
|
||||
_OnRefsReceived(message);
|
||||
break;
|
||||
|
||||
case MSG_SET_TARGET_TO_PARENT:
|
||||
_OnSetTargetToParent();
|
||||
break;
|
||||
|
||||
case B_CANCEL:
|
||||
_OnOpenPanelCancel();
|
||||
break;
|
||||
@ -417,6 +422,10 @@ GrepWindow::_CreateMenus()
|
||||
fOpen = new BMenuItem(
|
||||
B_TRANSLATE("Set target" B_UTF8_ELLIPSIS), new BMessage(MSG_OPEN_PANEL), 'F');
|
||||
|
||||
fSetTargetToParent = new BMenuItem(
|
||||
B_TRANSLATE("Set target to parent folder"),
|
||||
new BMessage(MSG_SET_TARGET_TO_PARENT), B_UP_ARROW);
|
||||
|
||||
fClose = new BMenuItem(
|
||||
B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), 'W');
|
||||
|
||||
@ -473,6 +482,7 @@ GrepWindow::_CreateMenus()
|
||||
fFileMenu->AddItem(fNew);
|
||||
fFileMenu->AddSeparatorItem();
|
||||
fFileMenu->AddItem(fOpen);
|
||||
fFileMenu->AddItem(fSetTargetToParent);
|
||||
fFileMenu->AddItem(fClose);
|
||||
fFileMenu->AddSeparatorItem();
|
||||
fFileMenu->AddItem(fQuit);
|
||||
@ -514,6 +524,15 @@ GrepWindow::_CreateMenus()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GrepWindow::_UpdateMenus()
|
||||
{
|
||||
bool targetIsSingleDirectory =
|
||||
BEntry(&(fModel->fDirectory)).InitCheck() == B_OK;
|
||||
fSetTargetToParent->SetEnabled(targetIsSingleDirectory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GrepWindow::_CreateViews()
|
||||
{
|
||||
@ -1431,6 +1450,7 @@ GrepWindow::_OnFileDrop(BMessage* message)
|
||||
fSearchResults->MakeEmpty();
|
||||
fOldPattern = "";
|
||||
|
||||
_UpdateMenus();
|
||||
_SetWindowTitle();
|
||||
}
|
||||
|
||||
@ -1504,6 +1524,23 @@ GrepWindow::_OnNewWindow()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GrepWindow::_OnSetTargetToParent()
|
||||
{
|
||||
BEntry entry(&(fModel->fDirectory));
|
||||
BEntry parent;
|
||||
|
||||
if (entry.GetParent(&parent) == B_OK) {
|
||||
entry_ref parent_ref;
|
||||
parent.GetRef(&parent_ref);
|
||||
|
||||
BMessage parentRefs;
|
||||
parentRefs.AddRef("dir_ref", &parent_ref);
|
||||
_OnFileDrop(&parentRefs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
@ -34,6 +34,7 @@ private:
|
||||
BMessage* message);
|
||||
void _SetWindowTitle();
|
||||
void _CreateMenus();
|
||||
void _UpdateMenus();
|
||||
void _CreateViews();
|
||||
void _LayoutViews();
|
||||
void _TileIfMultipleWindows();
|
||||
@ -72,6 +73,7 @@ private:
|
||||
void _OnOpenPanelCancel();
|
||||
void _OnSelectAll(BMessage* message);
|
||||
void _OnNewWindow();
|
||||
void _OnSetTargetToParent();
|
||||
|
||||
void _ModelChanged();
|
||||
bool _OpenInEditor(const entry_ref& ref, int32 lineNum);
|
||||
@ -89,6 +91,7 @@ private:
|
||||
BMenu* fFileMenu;
|
||||
BMenuItem* fNew;
|
||||
BMenuItem* fOpen;
|
||||
BMenuItem* fSetTargetToParent;
|
||||
BMenuItem* fClose;
|
||||
BMenuItem* fQuit;
|
||||
BMenu* fActionMenu;
|
||||
|
@ -41,6 +41,7 @@ enum {
|
||||
MSG_NEW_WINDOW,
|
||||
MSG_OPEN_PANEL,
|
||||
MSG_REFS_RECEIVED,
|
||||
MSG_SET_TARGET_TO_PARENT,
|
||||
MSG_TRY_QUIT,
|
||||
MSG_QUIT_NOW,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user