sqweek / dialog Goto Github PK
View Code? Open in Web Editor NEWSimple cross-platform dialog API for go-lang
License: ISC License
Simple cross-platform dialog API for go-lang
License: ISC License
go run main.go under Windows 10.
It would be great if the user could input something :)
MacOS version. 10.14.2
func fileRead() {
filename, err := dialog.File().Filter("pdf file", "pdf").Load()
if err != nil {
panic(err)
}
fmt.Println(filename)
// now read from that file name ...
}
func directoryRead() {
directory, err := dialog.Directory().Title("Load images").Browse()
if err != nil {
panic(err)
}
fmt.Println(directory)
}
Both work, but do get this error on the way through.
objc[39586]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff97ac1210) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x12abfdc8). One of the two will be used. Which one is undefined.
The directory browser on windows lets you choose certain shell folders such as "This PC" or attached MTP devices, which don't have an actual file system path.
The result is Browse()
returns an empty string and no error, which I think is a surprising result. We should make sure to return a valid filename in the no error case.
ok := dialog.Message("%s", "Do you want to continue?").Title("Are you sure?").YesNo()
log.Println(ok)
The code is like this, sometimes the Message cannot be displayed, sometimes it can be displayed, and the program is blocked when it is not displayed.
I write code on macOS, version: 11.0.1
But File and Directory can work normally.
Hello,
While building app on macos I get warnings specified below:
# github.com/sqweek/dialog/cocoa dlg.m:96:10: warning: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead [-Wdeprecated-declarations] /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
App builds itself, however it doesn't work properly.
There are some OS's which it shows on top but in some cases, the dialog appears minimized.
No error visible
Hi, under what license is this project published?
A good flavor from e.g. the Qt universe is to display dialog messages in a scroll area with selectable text. It makes it much easier for users to report problems in case of error messages because they can actually copy text instead of having to make a screencap (or worse: copying it manually). I'd like to request this because it can pose a huge improvement in user experience while not being a huge feature. Most typically it's programs like games which have bad error dialogs because they do their own rendering instead of using a native GUI (well, until it crashes and they have to fall back to displaying a plain old dialog box).
The current gtk implementation includes some code to execute gtk main loop iterations when closing a dialog, which is necessary for apps which don't otherwise use gtk so that the dialog actually disappears.
However, based on the initial changes proposed in #21 and @meskio's comments, it sounds like this stanza and/or the general approach to spawning dialogs doesn't interact overly well with apps which do use gtk.
Originally this was not a use-case I accounted for, because I figured gtk users already have a cross-platform way to spawn dialogs. But I guess there's an advantage to using the native file browser dialog when running on non-linux platforms so it would be nice to handle better.
(This is kind of similar to #15, where dialogs behave funny on osx if the app doesn't make other cocoa calls.)
Hi,
I'm facing unexpected error including github.com/sqweek/dialog
, clicking "Click Me" button, like in the following example:
Using alone both libraries working fine!
go get github.com/AllenDang/giu@latest
go get github.com/sqweek/dialog@latest
package main
import (
"fmt"
g "github.com/AllenDang/giu"
"github.com/sqweek/dialog"
)
func onClickMe() {
fmt.Println("Hello world!")
file, err := dialog.File().Title("Save As").Filter("All Files", "*").Save()
fmt.Println(file, err)
}
func onImSoCute() {
fmt.Println("Im sooooooo cute!!")
}
func loop() {
g.SingleWindow("hello world").Layout(
g.Label("Hello world from giu"),
g.Line(
g.Button("Click Me").OnClick(onClickMe),
g.Button("I'm so cute").OnClick(onImSoCute),
),
)
}
func main() {
wnd := g.NewMasterWindow("Hello world", 400, 200, g.MasterWindowFlagsNotResizable, nil)
wnd.Run(loop)
}
Reporting error:
Hello world!
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x7f030d6fefc4]
runtime stack:
runtime.throw(0x8c1f53, 0x2a)
/usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:718 +0x2e5
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x601e30, 0xc00011b8a8, 0x0)
/usr/local/go/src/runtime/cgocall.go:154 +0x5b fp=0xc00011b878 sp=0xc00011b840 pc=0x473e9b
github.com/sqweek/dialog._Cfunc_gtk_dialog_run(0x20162d0, 0x0)
_cgo_gotypes.go:236 +0x45 fp=0xc00011b8a8 sp=0xc00011b878 pc=0x5ffdc5
github.com/sqweek/dialog.chooseFile.func11(0x20162d0, 0x21e7b30)
/home/thenull/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:93 +0x4d fp=0xc00011b8d8 sp=0xc00011b8a8 pc=0x6012ed
github.com/sqweek/dialog.chooseFile(0x8b26f7, 0x9, 0x8b147e, 0x4, 0x1, 0xc00011bc20, 0x0, 0x0, 0x0, 0x0)
/home/thenull/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:93 +0x390 fp=0xc00011bb18 sp=0xc00011b8d8 pc=0x600890
github.com/sqweek/dialog.(*FileBuilder).save(...)
/home/thenull/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:59
github.com/sqweek/dialog.(*FileBuilder).Save(0xc00011bc20, 0x0, 0x0, 0x0, 0x1)
/home/thenull/go/pkg/mod/github.com/sqweek/[email protected]/dlgs.go:121 +0x65 fp=0xc00011bb78 sp=0xc00011bb18 pc=0x5ffb05
main.onClickMe()
/home/thenull/Sviluppo/dialogsqeak/dialog.go:31 +0x1cc fp=0xc00011bc68 sp=0xc00011bb78 pc=0x60188c
github.com/AllenDang/giu.(*ButtonWidget).Build(0xc00020a480)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/Widgets.go:114 +0x74 fp=0xc00011bc98 sp=0xc00011bc68 pc=0x5fedd4
github.com/AllenDang/giu.(*LineWidget).Build(0xc000204dc8)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/Widgets.go:49 +0xa8 fp=0xc00011bce0 sp=0xc00011bc98 pc=0x5fec68
github.com/AllenDang/giu.Layout.Build(0xc00011bd88, 0x2, 0x2)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/Layout.go:12 +0x6b fp=0xc00011bd08 sp=0xc00011bce0 pc=0x5fd34b
github.com/AllenDang/giu.(*WindowWidget).Layout(0xc0002006f0, 0xc00011bd88, 0x2, 0x2)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/Window.go:81 +0x109 fp=0xc00011bd40 sp=0xc00011bd08 pc=0x5ff449
main.loop()
/home/thenull/Sviluppo/dialogsqeak/dialog.go:40 +0x225 fp=0xc00011bdb8 sp=0xc00011bd40 pc=0x601c85
github.com/AllenDang/giu.(*MasterWindow).render(0xc0000a0000)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:174 +0xa4 fp=0xc00011be28 sp=0xc00011bdb8 pc=0x5fe7a4
github.com/AllenDang/giu.(*MasterWindow).run.func1()
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:192 +0x59 fp=0xc00011be68 sp=0xc00011be28 pc=0x5ff5f9
github.com/faiface/mainthread.Call.func1()
/home/thenull/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:63 +0x2f fp=0xc00011be98 sp=0xc00011be68 pc=0x566cef
github.com/faiface/mainthread.Run(0xc00009e4b0)
/home/thenull/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:44 +0xb1 fp=0xc00011bf20 sp=0xc00011be98 pc=0x566a71
github.com/AllenDang/giu.(*MasterWindow).Run(0xc0000a0000, 0x8c9d28)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:249 +0x65 fp=0xc00011bf40 sp=0xc00011bf20 pc=0x5fea45
main.main()
/home/thenull/Sviluppo/dialogsqeak/dialog.go:51 +0x70 fp=0xc00011bf88 sp=0xc00011bf40 pc=0x601d70
runtime.main()
/usr/local/go/src/runtime/proc.go:225 +0x256 fp=0xc00011bfe0 sp=0xc00011bf88 pc=0x4a8916
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc00011bfe8 sp=0xc00011bfe0 pc=0x4da3a1
goroutine 18 [chan receive]:
github.com/faiface/mainthread.Call(0xc0002006c0)
/home/thenull/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:66 +0xc5
github.com/AllenDang/giu.(*MasterWindow).run(0xc0000a0000)
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:190 +0xa5
github.com/AllenDang/giu.(*MasterWindow).Run.func1()
/home/thenull/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:254 +0x4d
github.com/faiface/mainthread.Run.func1(0xc00009e4b0, 0xc0000a6000)
/home/thenull/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:37 +0x27
created by github.com/faiface/mainthread.Run
/home/thenull/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:36 +0xa5
exit status 2
Gives error message
/github.com/AllenDang/w32/user32.go:1039: cannot use flag (type uint32) as type uintptr in argument to procRedrawWindow.Call
I'm making GUI application with Gio that uses GTK on linux, and application crashes on start (it's building well, breakes in dialog.init()
)
(projectName:16641): Gtk-ERROR **: 18:56:14.917: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported SIGTRAP: trace trap PC=0x7eff8415d92f m=0 sigcode=128 signal arrived during cgo executiongoroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x6f0e60, 0xc0000ddd00)
/usr/lib/go-1.18/src/runtime/cgocall.go:157 +0x5c fp=0xc0000ddcd8 sp=0xc0000ddca0 pc=0x42b2bc
github.com/sqweek/dialog._Cfunc_gtk_init(0x0, 0x0)
_cgo_gotypes.go:372 +0x45 fp=0xc0000ddd00 sp=0xc0000ddcd8 pc=0x6c26e5
github.com/sqweek/dialog.init.0()
/home/dikey0ficial/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:19 +0x30 fp=0xc0000ddd20 sp=0xc0000ddd00 pc=0x6c2af0
runtime.doInit(0xc2c4a0)
/usr/lib/go-1.18/src/runtime/proc.go:6222 +0x126 fp=0xc0000dde50 sp=0xc0000ddd20 pc=0x46a326
runtime.doInit(0xc300a0)
/usr/lib/go-1.18/src/runtime/proc.go:6199 +0x71 fp=0xc0000ddf80 sp=0xc0000dde50 pc=0x46a271
runtime.main()
/usr/lib/go-1.18/src/runtime/proc.go:233 +0x1d3 fp=0xc0000ddfe0 sp=0xc0000ddf80 pc=0x45d3d3
runtime.goexit()
/usr/lib/go-1.18/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000ddfe8 sp=0xc0000ddfe0 pc=0x489001rax 0x0
rbx 0x1
rcx 0xf
rdx 0x1629f33
rdi 0x7
rsi 0x15d0010
rbp 0x7fff5a833da0
rsp 0x7fff5a833d00
r8 0x1643240
r9 0x0
r10 0x7eff84af4040
r11 0x31c9c6bcdbafd93b
r12 0x6
r13 0x0
r14 0x7eff84231cc8
r15 0x7eff84231d50
rip 0x7eff8415d92f
rflags 0x202
cs 0x33
fs 0x0
gs 0x0
exit status 2
Enviroment info:
OS: Kubuntu 21.10 x86_64
Go: go1.18.1 linux/amd64
dialog version: v0.0.0-20220227145630-7a1c9e333fcf
gio version: v0.0.0-20220412071142-25fae8de30be
GTK3 version: 3.24.30
GTK2 version: 2.24.33
PR #10 revealed that the code violates a couple of golang code conventions:
dialog.Cancelled
error variable should be named dialog.ErrCancelled
Fixing the second breaks the API, so I want to have some kind of versioning scheme in place.
Hello,
While setting up my projects Github Workflows, I ran into an issue with your library which I would like to continue using if at all possible. The go get command was unable to located the pango library. I resolved the pipeline by removing the use of your code but as I said I would like to keep it if possible. I see that you removed pango regarding other issues so I am hoping you are able to find a solution to this.
Failed pipeline with dialog - https://github.com/bconn98/DrugRecord/runs/1308636059?check_suite_focus=true
Successful pipeline withou dialog - https://github.com/bconn98/DrugRecord/runs/1306842166?check_suite_focus=true
go version go1.9.2 darwin/amd64
x-MacBook-Pro:wde apple$ go build
# github.com/skelterjohn/go.wde/cocoa
EventWindow.m:207:40: warning: 'NSAlternateKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:184:35: note: 'NSAlternateKeyMask' has been explicitly marked deprecated here
EventWindow.m:208:40: warning: 'NSAlternateKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:184:35: note: 'NSAlternateKeyMask' has been explicitly marked deprecated here
EventWindow.m:209:40: warning: 'NSCommandKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:185:35: note: 'NSCommandKeyMask' has been explicitly marked deprecated here
EventWindow.m:210:40: warning: 'NSCommandKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:185:35: note: 'NSCommandKeyMask' has been explicitly marked deprecated here
EventWindow.m:211:40: warning: 'NSFunctionKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:188:35: note: 'NSFunctionKeyMask' has been explicitly marked deprecated here
EventWindow.m:212:40: warning: 'NSControlKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:183:35: note: 'NSControlKeyMask' has been explicitly marked deprecated here
EventWindow.m:213:40: warning: 'NSControlKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:183:35: note: 'NSControlKeyMask' has been explicitly marked deprecated here
EventWindow.m:214:40: warning: 'NSShiftKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:182:35: note: 'NSShiftKeyMask' has been explicitly marked deprecated here
EventWindow.m:215:40: warning: 'NSShiftKeyMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:182:35: note: 'NSShiftKeyMask' has been explicitly marked deprecated here
EventWindow.m:18:69: warning: conflicting parameter types in implementation of 'initWithContentRect:styleMask:backing:defer:': 'NSWindowStyleMask' (aka 'enum NSWindowStyleMask') vs 'NSUInteger' (aka 'unsigned long') [-Wmismatched-parameter-types]
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:295:86: note: previous definition is here
# github.com/skelterjohn/go.wde/cocoa
gmd.m:65:17: warning: 'NSTitledWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:955:32: note: 'NSTitledWindowMask' has been explicitly marked deprecated here
gmd.m:65:38: warning: 'NSClosableWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:956:32: note: 'NSClosableWindowMask' has been explicitly marked deprecated here
gmd.m:65:61: warning: 'NSMiniaturizableWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:957:32: note: 'NSMiniaturizableWindowMask' has been explicitly marked deprecated here
gmd.m:65:90: warning: 'NSResizableWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:958:32: note: 'NSResizableWindowMask' has been explicitly marked deprecated here
# github.com/gedw99/gitty/exp/ui/ci/desktop/dialog/wde
./main.go:19:8: undefined: wde
./main.go:20:12: e.Which undefined (type interface {} is interface with no methods)
./main.go:21:9: undefined: wde
./main.go:45:8: undefined: wde
./main.go:47:10: e.Glyph undefined (type interface {} is interface with no methods)
./main.go:49:10: e.Glyph undefined (type interface {} is interface with no methods)
./main.go:51:10: e.Glyph undefined (type interface {} is interface with no methods)
./main.go:54:8: undefined: wde
./main.go:55:4: undefined: wde
./main.go:63:11: undefined: wde
./main.go:63:11: too many errors
I encountered following error.
build github.com/sqweek/dialog/cocoa: cannot load github.com/sqweek/dialog/cocoa: no Go source files
Am i doing something wrong?
Win10 64bit
go1.13
using go module
@go.mod
github.com/sqweek/dialog v0.0.0-20200601143742-43ea34326190
package main
import (
"github.com/sqweek/dialog"
)
func main() {
dialog.Message("%s", "Please select a file").Title("Hello world!").Info()
}
set goos=darwin
set goarch=amd64
go build
build github.com/sqweek/dialog/cocoa: cannot load github.com/sqweek/dialog/cocoa: no Go source files
Hi, I just run go run main.go
on the package example dialog/example/simple/main.go
receiving the following messages:
pkg-config --cflags -- gtk+-3.0
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing gtk+-3.0.pc
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
pkg-config: exit status 1
On a Linux Mint amd64 machine with libgtk-3-0 already updated to (3.22.30-1ubuntu4).
Could you please suggest a solution?
Any interest in adding KDE support?
Hi,
it would be great to be able to tell which filter in save dialog user selected.
Imagine an application where user wants to export an image in one of possible graphic formats.
dial := dialog.File().Title("Export as image")
dial.Filter("SVG (*.svg)", "svg")
dial.Filter("PNG (*.png)", "png")
dial.Filter("PDF (*.pdf)", "pdf")
filename, err := dialog.Save()
User opens a dialog, selects png as type, and fill in just myimage as name, believing will create file myimage.png - which is common behavior and users are used to it - but it would not.
Problem is that value of variable filename
is just "myimage"
.
It would be great if either:
there would be a way to detect which which filter is selected
from nFilterIndex
field of OPENFILENAME
structure in win api
and from dialog.GetFilter()
in gtk lib on linux
it might by returned as additional value from .Save()
method.
or it could automatically append first extension from extensions of a selected filter to filename without extension
I'd be happy to help make an implementation for windows and linux platform.
YesNo dialog very inconsistent on MacOS.
I am using the same API given in the description
dialog.Message("%s", "Do you want to exit?").Title("Are you sure?").YesNo()
sometimes dialog wouldn't be shown and sometimes dialog stays on screen even if a button is clicked.
Can we have an options to make the message dialog appear always on top? I have a little program that works like an alarm. At a fixed time, I want it to show a message dialog. The message dialog appears, but it's burried under another application window. So it will be nice to have a dialog that will appear always on top of other application window.
The Microsoft docs say to use IFileDialog instead of SHBrowseForFolderA:
"For Windows Vista or later, it is recommended that you use IFileDialog with the FOS_PICKFOLDERS option rather than the SHBrowseForFolder function. This uses the Open Files dialog in pick folders mode and is the preferred implementation."
https://docs.microsoft.com/en-us/windows/win32/shell/common-file-dialog
https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifiledialog-setoptions
https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions
It doesn't look to me like the underlying win32 library you're using (github.com/TheTitanrain/w32) supports this COM interface, so this feature might be difficult to implement.
Here is a sample in c++ to show what is required:
https://cpp.hotexamples.com/examples/-/IFileDialog/Show/cpp-ifiledialog-show-method-examples.html
Here is the only Go project I could (easily) find that uses "CoCreateInstance" (e.g. wrappers/objbase.go):
https://github.com/winlabs/gowin32
Sorry I don't have more time to offer code for a PR. It looks like something that might be fun to work on.
Thank you for this great project.
As per title, can this functionality be added? As seen here: https://stackoverflow.com/questions/6942150/why-folderbrowserdialog-dialog-does-not-scroll-to-selected-folder
I have a test app that just creates a text file and writes a line to it:
package main
import "os"
func main() {
fp, err := os.OpenFile("test.txt", os.O_APPEND|os.O_CREATE, 0777)
if err != nil {
panic(err)
}
defer fp.Close()
fp.WriteString("This is a test")
}
I built this into an exe as "test.exe" and when I run it, it works as expected.
I have another app that uses the dialog
package:
package main
import (
"fmt"
"os/exec"
"github.com/sqweek/dialog"
)
func main() {
filedialog := dialog.File()
filename, err := filedialog.Load()
if err != nil {
fmt.Println(err)
}
fmt.Println(filename)
testapp := exec.Command("test.exe")
testapp.Start()
}
If i select a file through the filedialog, it correctly assigns the path as a string into the filename
variable, but text.exe never executes, i.e. "text.txt" never gets created. If i cancel the filedialog, "Cancelled" gets printed to stdout, and the "test.txt" file gets created.
For the record, I initially ran into this when running a different executable, I just created "test.exe" for illustrative purposes. What am I missing here?
Should we have support to set up the icon for the dialogs?
I have the code for linux: https://0xacab.org/leap/go-dialog/commit/887ac7700af3a5642c2d2e27d8ac56860d6622b6
But I haven't explore yet how to do it for windows and cocoa, or if it makes sense there.
I use win 10 x64, golang 1.10.4
github.com\AllenDang\w32\user32.go:1039:10: cannot use flag (type uint32) as type uintptr in argument to procRedrawWindow.Call
Looks like a new way in which Go passes pointers to C/C++/ObjC breaks the file dialogue open call on macOS.
Specific line:
cocoa/dlg.go:77
More information:
ry/v8worker#31
Hi there,
Would it be possible to add the ability to bring the dialog to the front of the window? Currently, it defaults to opening behind any running application.
Thanks,
Jer
Hi! Our project uses this great package.
We try to make cross compilation in docker image for darwin paltform.
We use docker image for golang cross platform building
https://hub.docker.com/r/dockercore/golang-cross/
And for darwin platform get this error
# github.com/sqweek/dialog/cocoa In file included from go/pkg/mod/github.com/sqweek/[email protected]/cocoa/dlg_darwin.go:6: ./dlg.h:1:10: fatal error: 'objc/NSObjcRuntime.h' file not found #include <objc/NSObjcRuntime.h>
We checked that this file is existed under SDK folder
/osxcross/target/SDK/MacOSX10.10.sdk/usr/include/objc
Builds for windows and linux platform passed successfully at the same image.
Is it possible to get some hints how to check what is wrong with build setup.
Thanks a lot!
I want to be able to select multiple files, but currently, I can only select one. I am using Windows 10-64bit.
Thanks a lot.
Build and test are working fine on windows machine but pipeline is failing on linux. Please suggest if there are any dependencies we have to download. Pipeline logs are
Unable to init server: Could not connect: Connection refused
(cpaas.test:225111): Gtk-WARNING **: 14:34:32.673: cannot open display:
go: downloading github.com/sqweek/dialog v0.0.0-20211002065838-9a201b55ab91
? bitbucket.org/gath3rio/cpaas-desktop-file-transfer/pkg/config [no test files]
Unable to init server: Could not connect: Connection refused
(cpaas.test:224311): Gtk-WARNING **: 14:31:47.868: cannot open display:
pkg-config --modversion gtk+-3.0
3.22.11
Thanks
Happens when building on Ubuntu 18, x64. Seems like the GTK URL has changed.
From the docs:
OSX: uses Cocoa's NSAlert/NSSavePanel/NSOpenPanel classes
Checking their docs, NSAlert / NSSavePanel / NSOpenPanel requires the macOS SDK 10.3+
.
We're tried to build a project using dialog
in a fairly old Mac with Xcode 7.2.1, which supports macOS SDK 10.11.2
, but we got these errors:
# github.com/sqweek/dialog/cocoa
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:43:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:6:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSString.h:38:
/System/Library/Frameworks/Foundation.framework/Headers/NSItemProvider.h:36:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSItemProvider.h:41:71: error: property has a previous declaration
/System/Library/Frameworks/Foundation.framework/Headers/NSItemProvider.h:36:78: note: property declared here
/System/Library/Frameworks/Foundation.framework/Headers/NSItemProvider.h:60:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:6:
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:290:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:296:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:11:
/System/Library/Frameworks/Foundation.framework/Headers/NSNotification.h:44:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:32:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:43:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:44:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:14:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSCalendar.h:7:
/System/Library/Frameworks/Foundation.framework/Headers/NSDate.h:45:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSDate.h:57:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSDate.h:58:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:14:
/System/Library/Frameworks/Foundation.framework/Headers/NSCalendar.h:106:12: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSCalendar.h:107:12: error: unknown property attribute 'class'
In file included from dlg.m:1:
In file included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:15:
/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h:20:22: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h:21:22: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h:22:22: error: unknown property attribute 'class'
/System/Library/Frameworks/Foundation.framework/Headers/NSCharacterSet.h:23:22: error: unknown property attribute 'class'
We tried in a different mac with Xcode 9.1 and it worked without any issues. Didn't try with Xcode 8, not sure whether it works with it.
Anyway, the point is: what is the actual minimum supported Xcode version - and perhaps it could be added to the docs by the required Cocoa's classes? I know most people are always on latest versions, but every now and then someone needs to run stuff in older machines and it's nice to know the exact requirements. ๐ก
$ go build
# pkg-config --cflags -- cairo cairo-gobject gobject-2.0
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Package cairo-gobject was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo-gobject.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo-gobject' found
pkg-config: exit status 1
# pkg-config --cflags -- gdk-3.0 glib-2.0 gobject-2.0
Package gdk-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdk-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-3.0' found
pkg-config: exit status 1
I suggest a change something like this to the readme although im not 100% sure what should go there, at least this worked for me on ubuntu:
objc[35224]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff8eddf210) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x14c3fdc8). One of the two will be used. Which one is undefined.
As the title says, setting FileDlg.StartDir has no effect on OSX.
(also I don't have a Mac handy any more for testing/development :S)
Hi, thanks for your work !
I'm running into a weird issue, I'm writing a gui application and when I click my button to open the file dialog it segfault. The thing that is very weird is that if at the start of my application (before running the main loop) i'm opening a file dialog it does it successfully and my button works after that (looks like gtk needs a warm up ๐ )
My call looks like that: tscw.newPath, _ = dialog.File().Load()
Here is the stacktrace:
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7f2d123ced74]
runtime stack:
runtime.throw(0x97b720, 0x2a)
/usr/lib/golang/src/runtime/panic.go:1116 +0x72
runtime.sigpanic()
/usr/lib/golang/src/runtime/signal_unix.go:679 +0x46a
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x867f10, 0xc000129930, 0x3962400)
/usr/lib/golang/src/runtime/cgocall.go:133 +0x5b fp=0xc000129900 sp=0xc0001298c8 pc=0x49c38b
github.com/gotk3/gotk3/gtk._Cfunc_gtk_dialog_run(0x3962400, 0x0)
_cgo_gotypes.go:8410 +0x49 fp=0xc000129930 sp=0xc000129900 pc=0x5d2119
github.com/gotk3/gotk3/gtk.(*Dialog).Run.func1(0xc00017f9b0, 0xc00017f901)
/home/hfabre/go/pkg/mod/github.com/gotk3/[email protected]/gtk/gtk.go:2963 +0x5b fp=0xc000129968 sp=0xc000129930 pc=0x66c1bb
github.com/gotk3/gotk3/gtk.(*Dialog).Run(0xc00017f9b0, 0x1)
/home/hfabre/go/pkg/mod/github.com/gotk3/[email protected]/gtk/gtk.go:2963 +0x2b fp=0xc000129988 sp=0xc000129968 pc=0x6238db
github.com/sqweek/dialog.chooseFile(0x974039, 0x9, 0x97362c, 0x4, 0x0, 0xc000129ba8, 0x0, 0x0, 0x0, 0x0)
/home/hfabre/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:79 +0x37c fp=0xc000129af8 sp=0xc000129988 pc=0x7a002c
github.com/sqweek/dialog.(*FileBuilder).load(...)
/home/hfabre/go/pkg/mod/github.com/sqweek/[email protected]/dlgs_linux.go:45
github.com/sqweek/dialog.(*FileBuilder).Load(0xc000129ba8, 0x41c8000042960000, 0x975033, 0xe, 0x101)
/home/hfabre/go/pkg/mod/github.com/sqweek/[email protected]/dlgs.go:112 +0x62 fp=0xc000129b58 sp=0xc000129af8 pc=0x79fb12
ttme/src.(*tilesetConfigurationWidget).Draw(0xc000129df0)
/home/hfabre/local/go/ttme/src/tleset_configuration_widget.go:27 +0x341 fp=0xc000129bf0 sp=0xc000129b58 pc=0x7a3501
ttme/src.(*app).Start(0xc000074480)
/home/hfabre/local/go/ttme/src/app.go:71 +0x326 fp=0xc000129f50 sp=0xc000129bf0 pc=0x7a08a6
main.main()
/home/hfabre/local/go/ttme/main.go:9 +0x56 fp=0xc000129f88 sp=0xc000129f50 pc=0x7a46a6
runtime.main()
/usr/lib/golang/src/runtime/proc.go:203 +0x1fa fp=0xc000129fe0 sp=0xc000129f88 pc=0x4cd06a
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc000129fe8 sp=0xc000129fe0 pc=0x4f7af1
exit status 2
make: *** [Makefile:4: run] Error 1
I feel like it's not very clear, ping me if you don't understand
Noticed some minor inconsistencies with other Gtk applications that also uses dialogs:
dlg.SetDoOverwriteConfirmation(true)
which automatically creates that dialog in case of an overwriteI could open a PR to address these if you want
Hi,
thanks for your work :)
is it possible to set a default location for a dialog?
Hello,
we cross built our application to macos, windows and linux. Sadly on Linux the above error gets shown on dialog.File().Load()
.
Whole error:
(surge-0.2.0-beta:2482): Gdk-ERROR **: 17:38:42.516: The program 'surge-0.2.0-beta' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadGC (invalid GC parameter)'.
(Details: serial 6173 error_code 13 request_code 60 (core protocol) minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
I built the linux app under latest Manjaro (clean VM installation). Any advices?
Cheers,
Chris
I suspect this is completely out of scope we are building a open source system using the golang GUI system called gio, and want to send pdfs to desktop printers.
It feels like a good idea to just talk directly to each OS's print preview API and send it a pdf ( or whatever it needs ).
If anyone has any tips in this area it would be great.
We want to of course make it a seperate open source golang lib that any golang GUI can reuse.
Again sorry if this is totally out of scope but it maybe that others dealing with the fun and games of desktop integration of golang GUI have the same frustrations as us.
Would it be possible to add functionality to define a recommended filename for the save dialog?
Currently on mac it defaults to Undefined and on windows it is just empty.
Greetings!
gotk3 does not allow you to pass nill parent for file choosers.
So, when I create a file dialog, my app crashes with NPE.
Am I do something wrong? If it's a bug, maybe it would be useful to populate FileBuilder with invisible window object that will be used as parent for file dialogs.
Can you please add an OK-Cancel Dialog? Sometimes we need to display an information message which has no need for user feedback. So, there is a need to display a message which only has an OK button or Ok-Cancel button.
Hi there,
(referring to OpenDiablo2/HellSpawner#216)
To Reproduce
func main() {
for {
dialog.Message("%s", "Please select a file").Titl
time.Sleep(1 * time.Second)
}
}
System Informations
OS: Fedora Workstation 33
desktop: GNOME Shell 3.38.3
I'd love to use this but my app already uses gtk3. Do you think I should make a pull request here or I would be better forking it?
I need to open a printer dialog so I can print a pdf from golang.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.