diff --git a/src/editor.jl b/src/editor.jl index abf8b403d3f060476ffa83f071b7b1e165e7cbf9..f60d99550f0f90148d03cbb74810843f25d2beaa 100644 --- a/src/editor.jl +++ b/src/editor.jl @@ -35,6 +35,8 @@ function larvaeditor(path=nothing; backend_directory::AbstractString=projectdir, manualtag::Union{Nothing, String, Symbol}="edited", title="LarvaTagger", + root_directory=nothing, + enable_uploads=false, kwargs...) # to (re-)load a file, the app is reloaded with the filepath as sole information @@ -47,6 +49,10 @@ function larvaeditor(path=nothing; # used for method dispatch (here `Session` is taken to represent Bonito) controller[:frontend] = Session + if !isnothing(root_directory) + controller[:workingdirectory] = workingdir(controller, root_directory) + end + tryopenfile(controller, input) editor = EditorView(larvaviewer(controller; @@ -56,7 +62,7 @@ function larvaeditor(path=nothing; larvafilter(controller), tagfilter(controller; manualtag=manualtag), metadataeditor(controller), - filemenu(controller), + filemenu(controller; upload_button=enable_uploads), backendmenu(controller, backend_directory), loadanimation(controller), twooptiondialog(controller)) diff --git a/src/files.jl b/src/files.jl index 397c78160d2df38634a5202d36675cc61b279c54..aa2e3d112c32dcf8e126bd8732b27c28daf82b38 100644 --- a/src/files.jl +++ b/src/files.jl @@ -7,7 +7,9 @@ struct WorkingDirectory content::Observable{Vector{String}} end -WorkingDirectory(controller, root::String, path::String="") = WorkingDirectory(controller, root, Validator(path), Observable(String[])) +function WorkingDirectory(controller, root::String, path::String="") + WorkingDirectory(controller, root, Validator(path), Observable(String[])) +end function workingdir(controller, root::String, path::String=""; secure::Bool=true) if secure @@ -107,7 +109,7 @@ function tryopenfile(controller, path; reload::Bool=false) @info "Cannot load file" file=path return elseif haskey(hub, :input) - hub[:input][] = isabspath(path) ? relpath(path) : path + hub[:input][] = path end # tag_lut fallback_color = theme[:LarvaPlot][:fallback_color] diff --git a/src/plots.jl b/src/plots.jl index 4a76a07e37abd5b8b02ec19cc83924fb95b49504..19cfa30f67bba9408fca99ac94d096b66792aa8f 100644 --- a/src/plots.jl +++ b/src/plots.jl @@ -562,7 +562,8 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva}) @assert hovering_active[] i = current_larva[] if i == j - @warn "moving too fast? - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues" + @warn "Moving too fast?" + return end if 0 < i i_decorated = larvae[i].decorated diff --git a/src/wgl.jl b/src/wgl.jl index 9bdb2a73ed716cd420fa39d7bcd5b54b57b76f2d..f20f9a2a01d34864b90e96903d864871ec3ad93d 100644 --- a/src/wgl.jl +++ b/src/wgl.jl @@ -902,10 +902,10 @@ struct FileMenu browser::FileBrowser end -function filemenu(controller; kwargs...) +function filemenu(controller; upload_button=false, kwargs...) wd = getworkingdir(controller) dir = joinpath(wd.root, wd.path[]) - browser = FileBrowser(dir; root=wd.root, upload_button=false) + browser = FileBrowser(dir; root=wd.root, upload_button=upload_button) on(FileBrowsers.selectedfile(browser)) do file tryopenfile(controller, file; reload=true) end @@ -920,6 +920,7 @@ function filemenu(controller; kwargs...) on(FilePickers.uploadedfile(browser)) do fileinfo filepath = joinpath(workingdir[], fileinfo["name"]) saveinputfile(filepath, fileinfo["content"]) + notify(workingdir) end end return FileMenu(gethub(controller), browser)