Documentation, fixes.
This commit is contained in:
parent
18e4c20ad5
commit
457b020545
4 changed files with 11 additions and 10 deletions
|
@ -3,6 +3,7 @@ package zenity
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -311,14 +312,14 @@ func browseForFolder(opts options) (string, []string, error) {
|
||||||
args.Title = syscall.StringToUTF16Ptr(*opts.title)
|
args.Title = syscall.StringToUTF16Ptr(*opts.title)
|
||||||
}
|
}
|
||||||
if opts.filename != "" {
|
if opts.filename != "" {
|
||||||
ptr := syscall.StringToUTF16Ptr(opts.filename)
|
args.LParam = strptr(opts.filename)
|
||||||
args.LParam = uintptr(unsafe.Pointer(ptr))
|
|
||||||
args.CallbackFunc = syscall.NewCallback(func(wnd uintptr, msg uint32, lparam, data uintptr) uintptr {
|
args.CallbackFunc = syscall.NewCallback(func(wnd uintptr, msg uint32, lparam, data uintptr) uintptr {
|
||||||
if msg == 1 { // BFFM_INITIALIZED
|
if msg == 1 { // BFFM_INITIALIZED
|
||||||
sendMessage.Call(wnd, 1024+103 /* BFFM_SETSELECTIONW */, 1 /* TRUE */, data)
|
sendMessage.Call(wnd, 1024+103 /* BFFM_SETSELECTIONW */, 1 /* TRUE */, data)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
defer runtime.KeepAlive(opts.filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.ctx != nil {
|
if opts.ctx != nil {
|
||||||
|
|
4
list.go
4
list.go
|
@ -27,14 +27,14 @@ func ListMultiple(text string, items []string, options ...Option) ([]string, err
|
||||||
return listMultiple(text, items, applyOptions(options))
|
return listMultiple(text, items, applyOptions(options))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMultiple displays the list dialog, allowing multiple items to be selected.
|
// ListMultipleItems displays the list dialog, allowing multiple items to be selected.
|
||||||
//
|
//
|
||||||
// Returns a nil slice on cancel, or ErrExtraButton.
|
// Returns a nil slice on cancel, or ErrExtraButton.
|
||||||
func ListMultipleItems(text string, items ...string) ([]string, error) {
|
func ListMultipleItems(text string, items ...string) ([]string, error) {
|
||||||
return ListMultiple(text, items)
|
return ListMultiple(text, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultItems returns an Option to set the items to initally select (macOS only).
|
// DefaultItems returns an Option to set the items to initially select (macOS only).
|
||||||
func DefaultItems(items ...string) Option {
|
func DefaultItems(items ...string) Option {
|
||||||
return funcOption(func(o *options) { o.defaultItems = items })
|
return funcOption(func(o *options) { o.defaultItems = items })
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package zenity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
@ -55,6 +56,7 @@ func message(kind messageKind, text string, opts options) (bool, error) {
|
||||||
var title uintptr
|
var title uintptr
|
||||||
if opts.title != nil {
|
if opts.title != nil {
|
||||||
title = strptr(*opts.title)
|
title = strptr(*opts.title)
|
||||||
|
defer runtime.KeepAlive(*opts.title)
|
||||||
}
|
}
|
||||||
|
|
||||||
s, _, err := messageBox.Call(0, strptr(text), title, flags)
|
s, _, err := messageBox.Call(0, strptr(text), title, flags)
|
||||||
|
|
|
@ -409,15 +409,13 @@ func uuid(s string) uintptr {
|
||||||
type _COMObject struct{}
|
type _COMObject struct{}
|
||||||
|
|
||||||
func (o *_COMObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
|
func (o *_COMObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
|
||||||
self := uintptr(unsafe.Pointer(o))
|
switch nargs := uintptr(len(a)); nargs {
|
||||||
nargs := uintptr(len(a))
|
|
||||||
switch nargs {
|
|
||||||
case 0:
|
case 0:
|
||||||
return syscall.Syscall(trap, nargs+1, self, 0, 0)
|
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(o)), 0, 0)
|
||||||
case 1:
|
case 1:
|
||||||
return syscall.Syscall(trap, nargs+1, self, a[0], 0)
|
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(o)), a[0], 0)
|
||||||
case 2:
|
case 2:
|
||||||
return syscall.Syscall(trap, nargs+1, self, a[0], a[1])
|
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(o)), a[0], a[1])
|
||||||
default:
|
default:
|
||||||
panic("COM call with too many arguments.")
|
panic("COM call with too many arguments.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue