ncruces / zenity

Zenity dialogs for Golang, Windows, macOS
https://pkg.go.dev/github.com/ncruces/zenity
MIT License
736 stars 37 forks source link

zenity file-selection #75

Closed jeesk closed 1 year ago

jeesk commented 1 year ago

Is there any way to implement this on linux, where the file selector is opened in the application and attached to a window? I'm using attach to a window id, and found that it doesn't work on arch linux.

jeesk commented 1 year ago

I used wmctrl - l to obtain the window ID, but it did not work.

import (
    "github.com/gin-gonic/gin"
    "github.com/ncruces/zenity"
    "net/http"
    "strings"
)

func main() {

    r := gin.Default()
    r.GET("/ping", func(c *gin.Context) {
        file, err := zenity.SelectFileMultiple(
            zenity.Attach(4915245),
            zenity.FileFilters{
                {"Go files", []string{"*.go"}, false},
                {"Web files", []string{"*.html", "*.js", "*.css"}, true},
                {"Image files", []string{"*.png", "*.gif", "*.ico", "*.jpg", "*.webp"}, true},
            })

        if err != nil {
            c.JSON(http.StatusInternalServerError, err.Error())
        }
        c.JSON(http.StatusOK, gin.H{
            "files": strings.Join(file, ","),
        })
    })
    r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
ncruces commented 1 year ago

Did you try running the command line zenity to check if it works? If it doesn't, there's very little I can do.

jeesk commented 1 year ago

Did you try running the command line zenity to check if it works? If it doesn't, there's very little I can do.

It can work normally, but there is no effect of Chrome or Firefox opening the modal box of the file selector.

ncruces commented 1 year ago

My point is, on Linux, does running zenity with --attach and --modal work as you want/expect?

If it does, there's something I can do about it, otherwise there really… isn't.

ncruces commented 1 year ago

Closing as there doesn't seem to be anything I can do to improve the situation. If you have any concrete suggestion (a zenity command I could/should be running), please reopen the issue.