More go fmt.
This commit is contained in:
parent
86cf5489d3
commit
ad8a90ec7e
|
@ -2,10 +2,6 @@
|
|||
|
||||
package ui
|
||||
|
||||
import (
|
||||
// ...
|
||||
)
|
||||
|
||||
// sentinel (not nil so programmer errors don't go undetected)
|
||||
// this window is invalid and cannot be used directly
|
||||
var dialogWindow = new(Window)
|
||||
|
@ -15,7 +11,7 @@ var dialogWindow = new(Window)
|
|||
// Optionally, secondaryText can be used to show additional information.
|
||||
// If you pass an empty string for secondaryText, neither additional information nor space for additional information will be shown.
|
||||
// On platforms that allow for the message box window to have a title, os.Args[0] is used.
|
||||
//
|
||||
//
|
||||
// See "On Dialogs" in the package overview for behavioral information.
|
||||
func MsgBox(primaryText string, secondaryText string) {
|
||||
<-dialogWindow.msgBox(primaryText, secondaryText)
|
||||
|
@ -32,7 +28,7 @@ func (w *Window) MsgBox(primaryText string, secondaryText string) (done chan str
|
|||
|
||||
// MsgBoxError displays a message box to the user with just an OK button and an icon indicating an error.
|
||||
// Otherwise, it behaves like MsgBox.
|
||||
//
|
||||
//
|
||||
// See "On Dialogs" in the package overview for more information.
|
||||
func MsgBoxError(primaryText string, secondaryText string) {
|
||||
<-dialogWindow.msgBoxError(primaryText, secondaryText)
|
||||
|
|
|
@ -12,7 +12,7 @@ import "C"
|
|||
//export dialog_send
|
||||
func dialog_send(pchan unsafe.Pointer, res C.intptr_t) {
|
||||
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)
|
||||
}()
|
||||
}
|
||||
|
@ -31,9 +31,9 @@ func _msgBox(parent *Window, primarytext string, secondarytext string, style uin
|
|||
secondary = toNSString(secondarytext)
|
||||
}
|
||||
switch style {
|
||||
case 0: // normal
|
||||
case 0: // normal
|
||||
C.msgBox(pwin, primary, secondary, unsafe.Pointer(&ret))
|
||||
case 1: // error
|
||||
case 1: // error
|
||||
C.msgBoxError(pwin, primary, secondary, unsafe.Pointer(&ret))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
// static inline GtkWidget *gtkNewMsgBox(GtkWindow *parent, GtkMessageType type, GtkButtonsType buttons, char *title, char *text)
|
||||
// {
|
||||
// GtkWidget *k;
|
||||
//
|
||||
//
|
||||
// k = gtk_message_dialog_new(parent, GTK_DIALOG_MODAL, type, buttons, "%s", (gchar *) title);
|
||||
// if (text != NULL)
|
||||
// gtk_message_dialog_format_secondary_text((GtkMessageDialog *) k, "%s", (gchar *) text);
|
||||
|
@ -25,18 +25,18 @@ import "C"
|
|||
|
||||
// dialog performs the bookkeeping involved for having a GtkDialog behave the way we want.
|
||||
type dialog struct {
|
||||
parent *Window
|
||||
pwin *C.GtkWindow
|
||||
hadgroup C.gboolean
|
||||
prevgroup *C.GtkWindowGroup
|
||||
newgroup *C.GtkWindowGroup
|
||||
result chan int
|
||||
parent *Window
|
||||
pwin *C.GtkWindow
|
||||
hadgroup C.gboolean
|
||||
prevgroup *C.GtkWindowGroup
|
||||
newgroup *C.GtkWindowGroup
|
||||
result chan int
|
||||
}
|
||||
|
||||
func mkdialog(parent *Window) *dialog {
|
||||
return &dialog{
|
||||
parent: parent,
|
||||
result: make(chan int),
|
||||
parent: parent,
|
||||
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) {
|
||||
d := (*dialog)(unsafe.Pointer(data))
|
||||
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)
|
||||
|
@ -94,10 +94,10 @@ func (d *dialog) cleanup(box *C.GtkWidget) {
|
|||
C.gtk_widget_destroy(box)
|
||||
if d.parent != dialogWindow {
|
||||
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 {
|
||||
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)
|
||||
if parent != dialogWindow {
|
||||
parenthwnd = parent.sysData.hwnd
|
||||
uType |= _MB_APPLMODAL // only for this window
|
||||
uType |= _MB_APPLMODAL // only for this window
|
||||
} 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)
|
||||
go func() {
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
call: _messageBox,
|
||||
p: []uintptr{
|
||||
call: _messageBox,
|
||||
p: []uintptr{
|
||||
uintptr(parenthwnd),
|
||||
utf16ToArg(ptext),
|
||||
utf16ToArg(ptitle),
|
||||
uintptr(uType),
|
||||
},
|
||||
ret: ret,
|
||||
ret: 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))
|
||||
}
|
||||
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{}) {
|
||||
done = make(chan struct{})
|
||||
go func() {
|
||||
<-_msgBox(w, primarytext, secondarytext, _MB_OK | _MB_ICONERROR)
|
||||
<-_msgBox(w, primarytext, secondarytext, _MB_OK|_MB_ICONERROR)
|
||||
done <- struct{}{}
|
||||
}()
|
||||
return done
|
||||
|
|
Loading…
Reference in New Issue