More go fmt.
This commit is contained in:
parent
86cf5489d3
commit
ad8a90ec7e
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
|
||||||
// ...
|
|
||||||
)
|
|
||||||
|
|
||||||
// sentinel (not nil so programmer errors don't go undetected)
|
// sentinel (not nil so programmer errors don't go undetected)
|
||||||
// this window is invalid and cannot be used directly
|
// this window is invalid and cannot be used directly
|
||||||
var dialogWindow = new(Window)
|
var dialogWindow = new(Window)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import "C"
|
||||||
//export dialog_send
|
//export dialog_send
|
||||||
func dialog_send(pchan unsafe.Pointer, res C.intptr_t) {
|
func dialog_send(pchan unsafe.Pointer, res C.intptr_t) {
|
||||||
rchan := (*chan int)(pchan)
|
rchan := (*chan int)(pchan)
|
||||||
go func() { // send it in a new goroutine like we do with everything else
|
go func() { // send it in a new goroutine like we do with everything else
|
||||||
*rchan <- int(res)
|
*rchan <- int(res)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ func _msgBox(parent *Window, primarytext string, secondarytext string, style uin
|
||||||
secondary = toNSString(secondarytext)
|
secondary = toNSString(secondarytext)
|
||||||
}
|
}
|
||||||
switch style {
|
switch style {
|
||||||
case 0: // normal
|
case 0: // normal
|
||||||
C.msgBox(pwin, primary, secondary, unsafe.Pointer(&ret))
|
C.msgBox(pwin, primary, secondary, unsafe.Pointer(&ret))
|
||||||
case 1: // error
|
case 1: // error
|
||||||
C.msgBoxError(pwin, primary, secondary, unsafe.Pointer(&ret))
|
C.msgBoxError(pwin, primary, secondary, unsafe.Pointer(&ret))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,18 @@ import "C"
|
||||||
|
|
||||||
// dialog performs the bookkeeping involved for having a GtkDialog behave the way we want.
|
// dialog performs the bookkeeping involved for having a GtkDialog behave the way we want.
|
||||||
type dialog struct {
|
type dialog struct {
|
||||||
parent *Window
|
parent *Window
|
||||||
pwin *C.GtkWindow
|
pwin *C.GtkWindow
|
||||||
hadgroup C.gboolean
|
hadgroup C.gboolean
|
||||||
prevgroup *C.GtkWindowGroup
|
prevgroup *C.GtkWindowGroup
|
||||||
newgroup *C.GtkWindowGroup
|
newgroup *C.GtkWindowGroup
|
||||||
result chan int
|
result chan int
|
||||||
}
|
}
|
||||||
|
|
||||||
func mkdialog(parent *Window) *dialog {
|
func mkdialog(parent *Window) *dialog {
|
||||||
return &dialog{
|
return &dialog{
|
||||||
parent: parent,
|
parent: parent,
|
||||||
result: make(chan int),
|
result: make(chan int),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ func (d *dialog) run(mk func() *C.GtkWidget) {
|
||||||
func our_dialog_response_callback(box *C.GtkDialog, res C.gint, data C.gpointer) {
|
func our_dialog_response_callback(box *C.GtkDialog, res C.gint, data C.gpointer) {
|
||||||
d := (*dialog)(unsafe.Pointer(data))
|
d := (*dialog)(unsafe.Pointer(data))
|
||||||
d.cleanup((*C.GtkWidget)(unsafe.Pointer(box)))
|
d.cleanup((*C.GtkWidget)(unsafe.Pointer(box)))
|
||||||
go d.send(res) // send on another goroutine, like everything else
|
go d.send(res) // send on another goroutine, like everything else
|
||||||
}
|
}
|
||||||
|
|
||||||
var dialog_response_callback = C.GCallback(C.our_dialog_response_callback)
|
var dialog_response_callback = C.GCallback(C.our_dialog_response_callback)
|
||||||
|
@ -94,10 +94,10 @@ func (d *dialog) cleanup(box *C.GtkWidget) {
|
||||||
C.gtk_widget_destroy(box)
|
C.gtk_widget_destroy(box)
|
||||||
if d.parent != dialogWindow {
|
if d.parent != dialogWindow {
|
||||||
C.gtk_window_group_remove_window(d.newgroup, d.pwin)
|
C.gtk_window_group_remove_window(d.newgroup, d.pwin)
|
||||||
C.g_object_unref(C.gpointer(unsafe.Pointer(d.newgroup))) // free the group
|
C.g_object_unref(C.gpointer(unsafe.Pointer(d.newgroup))) // free the group
|
||||||
if d.prevgroup != nil {
|
if d.prevgroup != nil {
|
||||||
C.gtk_window_group_add_window(d.prevgroup, d.pwin)
|
C.gtk_window_group_add_window(d.prevgroup, d.pwin)
|
||||||
} // otherwise it'll go back into the default group on its own
|
} // otherwise it'll go back into the default group on its own
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,26 +22,26 @@ func _msgBox(parent *Window, primarytext string, secondarytext string, uType uin
|
||||||
parenthwnd := _HWND(_NULL)
|
parenthwnd := _HWND(_NULL)
|
||||||
if parent != dialogWindow {
|
if parent != dialogWindow {
|
||||||
parenthwnd = parent.sysData.hwnd
|
parenthwnd = parent.sysData.hwnd
|
||||||
uType |= _MB_APPLMODAL // only for this window
|
uType |= _MB_APPLMODAL // only for this window
|
||||||
} else {
|
} else {
|
||||||
uType |= _MB_TASKMODAL // make modal to every window in the program (they're all windows of the uitask, which is a single thread)
|
uType |= _MB_TASKMODAL // make modal to every window in the program (they're all windows of the uitask, which is a single thread)
|
||||||
}
|
}
|
||||||
retchan := make(chan int)
|
retchan := make(chan int)
|
||||||
go func() {
|
go func() {
|
||||||
ret := make(chan uiret)
|
ret := make(chan uiret)
|
||||||
defer close(ret)
|
defer close(ret)
|
||||||
uitask <- &uimsg{
|
uitask <- &uimsg{
|
||||||
call: _messageBox,
|
call: _messageBox,
|
||||||
p: []uintptr{
|
p: []uintptr{
|
||||||
uintptr(parenthwnd),
|
uintptr(parenthwnd),
|
||||||
utf16ToArg(ptext),
|
utf16ToArg(ptext),
|
||||||
utf16ToArg(ptitle),
|
utf16ToArg(ptitle),
|
||||||
uintptr(uType),
|
uintptr(uType),
|
||||||
},
|
},
|
||||||
ret: ret,
|
ret: ret,
|
||||||
}
|
}
|
||||||
r := <-ret
|
r := <-ret
|
||||||
if r.ret == 0 { // failure
|
if r.ret == 0 { // failure
|
||||||
panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", r.err, uType, os.Args[0], text))
|
panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", r.err, uType, os.Args[0], text))
|
||||||
}
|
}
|
||||||
retchan <- int(r.ret)
|
retchan <- int(r.ret)
|
||||||
|
@ -61,7 +61,7 @@ func (w *Window) msgBox(primarytext string, secondarytext string) (done chan str
|
||||||
func (w *Window) msgBoxError(primarytext string, secondarytext string) (done chan struct{}) {
|
func (w *Window) msgBoxError(primarytext string, secondarytext string) (done chan struct{}) {
|
||||||
done = make(chan struct{})
|
done = make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
<-_msgBox(w, primarytext, secondarytext, _MB_OK | _MB_ICONERROR)
|
<-_msgBox(w, primarytext, secondarytext, _MB_OK|_MB_ICONERROR)
|
||||||
done <- struct{}{}
|
done <- struct{}{}
|
||||||
}()
|
}()
|
||||||
return done
|
return done
|
||||||
|
|
Loading…
Reference in New Issue