This commit is contained in:
nakst 2021-10-13 21:19:47 +01:00
parent 2e1327046c
commit 15cb0eeafd
4 changed files with 14 additions and 13 deletions

View File

@ -31,14 +31,21 @@ bool InstanceLoadFolder(Instance *instance, String path /* takes ownership */, i
instance->issuedPasteTask = nullptr; instance->issuedPasteTask = nullptr;
InstanceRemoveContents(instance);
FolderAttachInstance(instance, path, false);
StringDestroy(&path);
Task task = {}; Task task = {};
task.context = historyMode; task.context = historyMode;
task.cDescription = interfaceString_FileManagerOpenFolderTask; task.cDescription = interfaceString_FileManagerOpenFolderTask;
EsListViewIndex focusedIndex;
if (EsListViewGetFocusedItem(instance->list, nullptr, &focusedIndex)) {
String name = instance->listContents[focusedIndex].entry->GetName();
task.string = StringDuplicate(name);
}
InstanceRemoveContents(instance);
FolderAttachInstance(instance, path, false);
StringDestroy(&path);
task.callback = [] (Instance *instance, Task *) { task.callback = [] (Instance *instance, Task *) {
Folder *folder = instance->folder; Folder *folder = instance->folder;
EsMutexAcquire(&folder->modifyEntriesMutex); EsMutexAcquire(&folder->modifyEntriesMutex);
@ -70,13 +77,7 @@ bool InstanceLoadFolder(Instance *instance, String path /* takes ownership */, i
HistoryEntry historyEntry = {}; HistoryEntry historyEntry = {};
historyEntry.path = instance->path; historyEntry.path = instance->path;
historyEntry.focusedItem = task->string;
EsListViewIndex focusedIndex;
if (EsListViewGetFocusedItem(instance->list, nullptr, &focusedIndex)) {
String name = instance->listContents[focusedIndex].entry->GetName();
historyEntry.focusedItem = StringDuplicate(name);
}
if (historyMode == LOAD_FOLDER_BACK) { if (historyMode == LOAD_FOLDER_BACK) {
instance->pathForwardHistory.Add(historyEntry); instance->pathForwardHistory.Add(historyEntry);

View File

@ -1573,10 +1573,10 @@ void EsCommandAddButton(EsCommand *command, EsButton *button) {
Array<EsElement *> elements = { command->elements }; Array<EsElement *> elements = { command->elements };
elements.Add(button); elements.Add(button);
command->elements = elements.array; command->elements = elements.array;
EsButtonOnCommand(button, command->callback, command);
button->state |= UI_STATE_COMMAND_BUTTON; button->state |= UI_STATE_COMMAND_BUTTON;
EsElementSetEnabled(button, command->enabled); EsElementSetEnabled(button, command->enabled);
EsButtonSetCheck(button, command->check); EsButtonSetCheck(button, command->check); // Set the check before setting the callback, so that it doesn't get called.
EsButtonOnCommand(button, command->callback, command);
} }
EsCommand *EsCommandRegister(EsCommand *command, EsInstance *_instance, EsCommand *EsCommandRegister(EsCommand *command, EsInstance *_instance,

Binary file not shown.

Binary file not shown.