Added the new MsgBox() behavior to the GTK+ backend. It /almost/ works right; just needs some more changes...

This commit is contained in:
Pietro Gagliardi 2014-06-08 10:07:44 -04:00
parent 641d11c6fe
commit 15afca6402
1 changed files with 63 additions and 49 deletions

View File

@ -22,7 +22,9 @@ import (
// } // }
import "C" import "C"
func _msgBox(parent *Window, primarytext string, secondarytext string, msgtype C.GtkMessageType, buttons C.GtkButtonsType) (result C.gint) { func _msgBox(parent *Window, primarytext string, secondarytext string, msgtype C.GtkMessageType, buttons C.GtkButtonsType) (result chan int) {
result = make(chan int)
go func() {
ret := make(chan C.gint) ret := make(chan C.gint)
defer close(ret) defer close(ret)
uitask <- func() { uitask <- func() {
@ -68,13 +70,25 @@ func _msgBox(parent *Window, primarytext string, secondarytext string, msgtype C
ret <- response ret <- response
} }
return <-ret result <- int(<-ret)
}()
return result
} }
func msgBox(parent *Window, primarytext string, secondarytext string) { func (w *Window) msgBox(primarytext string, secondarytext string) (done chan struct{}) {
_msgBox(parent, primarytext, secondarytext, C.GtkMessageType(C.GTK_MESSAGE_OTHER), C.GtkButtonsType(C.GTK_BUTTONS_OK)) done = make(chan struct{})
go func() {
<-_msgBox(w, primarytext, secondarytext, C.GtkMessageType(C.GTK_MESSAGE_OTHER), C.GtkButtonsType(C.GTK_BUTTONS_OK))
done <- struct{}{}
}()
return done
} }
func msgBoxError(parent *Window, primarytext string, secondarytext string) { func (w *Window) msgBoxError(primarytext string, secondarytext string) (done chan struct{}) {
_msgBox(parent, primarytext, secondarytext, C.GtkMessageType(C.GTK_MESSAGE_ERROR), C.GtkButtonsType(C.GTK_BUTTONS_OK)) done = make(chan struct{})
go func() {
<-_msgBox(w, primarytext, secondarytext, C.GtkMessageType(C.GTK_MESSAGE_ERROR), C.GtkButtonsType(C.GTK_BUTTONS_OK))
done <- struct{}{}
}()
return done
} }