Documentation, fixes.

This commit is contained in:
Nuno Cruces 2021-04-09 15:28:17 +01:00
parent 18e4c20ad5
commit 457b020545
4 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package zenity
import (
"path/filepath"
"reflect"
"runtime"
"syscall"
"unicode/utf16"
"unsafe"
@ -311,14 +312,14 @@ func browseForFolder(opts options) (string, []string, error) {
args.Title = syscall.StringToUTF16Ptr(*opts.title)
}
if opts.filename != "" {
ptr := syscall.StringToUTF16Ptr(opts.filename)
args.LParam = uintptr(unsafe.Pointer(ptr))
args.LParam = strptr(opts.filename)
args.CallbackFunc = syscall.NewCallback(func(wnd uintptr, msg uint32, lparam, data uintptr) uintptr {
if msg == 1 { // BFFM_INITIALIZED
sendMessage.Call(wnd, 1024+103 /* BFFM_SETSELECTIONW */, 1 /* TRUE */, data)
}
return 0
})
defer runtime.KeepAlive(opts.filename)
}
if opts.ctx != nil {

View File

@ -27,14 +27,14 @@ func ListMultiple(text string, items []string, options ...Option) ([]string, err
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.
func ListMultipleItems(text string, items ...string) ([]string, error) {
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 {
return funcOption(func(o *options) { o.defaultItems = items })
}

View File

@ -2,6 +2,7 @@ package zenity
import (
"context"
"runtime"
"syscall"
"unsafe"
)
@ -55,6 +56,7 @@ func message(kind messageKind, text string, opts options) (bool, error) {
var title uintptr
if opts.title != nil {
title = strptr(*opts.title)
defer runtime.KeepAlive(*opts.title)
}
s, _, err := messageBox.Call(0, strptr(text), title, flags)

View File

@ -409,15 +409,13 @@ func uuid(s string) uintptr {
type _COMObject struct{}
func (o *_COMObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
self := uintptr(unsafe.Pointer(o))
nargs := uintptr(len(a))
switch nargs {
switch nargs := uintptr(len(a)); nargs {
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:
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:
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:
panic("COM call with too many arguments.")
}