The owner, on the v0.1.2442 sheet: the extension was written to ~/.config/magpie/browser-extension, a hidden folder no one can find to choose in Load unpacked. - Set up writes it to "Magpie Browser Extension" in the home folder (browserExtDir), where Finder and Explorer show it, and shows it selected in its parent (open -R on the Mac, explorer /select, on Windows, the home folder on Linux) rather than opened, to drag from. - On the Mac the sheet has the folder itself: a press on it that moves hands the folder to the system's drag (POST /api/library/browser/drag, filedrag_darwin.go: beginDraggingSession from the key window with a file URL and the folder's icon, only while the button is still down), so it drops onto chrome://extensions as from Finder. Chromium's extensions page loads a dropped folder as unpacked (drag_and_drop_handler.ts: entry.isDirectory -> loadUnpackedFromDrag), with Developer mode on, which step 2 asks for. - Elsewhere step 3 says to drag the folder from the window that opened, or Load unpacked and choose it. - Old installs: a browser that loaded the hidden folder still does, and that folder is kept up to date as long as it has a manifest; the sheet offers set up again, into the new folder. Run atace58117aon mote: go vet ./internal/gui (darwin), GOOS=linux -tags nogui and GOOS=windows vet; library-browser-setup and i18n-keys GUI tests, 46 of 46 (5 languages, Chromium and WebKit, 1100 and 420 wide, with and without the drag: a click posts no drag, a press that moves posts one); internal/cli parity tests ok. Atdf0320156: go test ./internal/gui ./internal/cli, cli ok, gui red only in TestMainWindowCorners, which is #3949 and red the same atdf0320156without this change. Not tried: the native drag by hand into a real Chrome (no way to drive a mouse drag here), and Explorer's /select on the Windows box.
31 lines
712 B
Go
31 lines
712 B
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"syscall"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
"github.com/yetone/magpie/internal/proc"
|
|
)
|
|
|
|
// revealFolder shows the folder selected in its parent's Explorer window,
|
|
// to drag from there: started and left to open, as openFolder does.
|
|
func revealFolder(_ *application.App, path string) error {
|
|
if _, err := os.Stat(path); err != nil {
|
|
return err
|
|
}
|
|
cmd := proc.Command(explorer())
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.CmdLine = fmt.Sprintf(`explorer.exe /select,"%s"`, path)
|
|
if err := cmd.Start(); err != nil {
|
|
return fmt.Errorf("explorer: %w", err)
|
|
}
|
|
go cmd.Wait()
|
|
return nil
|
|
}
|