From b2f408abfc405da9b28912e5e790c9277b6e8a77 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Fri, 10 Jun 2016 01:34:16 +0300 Subject: [PATCH 1/2] OpenFile, SaveFile and MsgBox dialogs --- stddialogs.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/stddialogs.go b/stddialogs.go index ed12772..f30c75f 100644 --- a/stddialogs.go +++ b/stddialogs.go @@ -5,8 +5,6 @@ package ui // #include "ui.h" import "C" -// TODO OpenFile, SaveFile, MsgBox - // TODO func MsgBoxError(w *Window, title string, description string) { ctitle := C.CString(title) @@ -15,3 +13,25 @@ func MsgBoxError(w *Window, title string, description string) { freestr(ctitle) freestr(cdescription) } + +func OpenFile(w *Window) string { + cname := C.uiOpenFile(w.w) + name := C.GoString(cname) + freestr(cname) + return name +} + +func SaveFile(w *Window) string { + cname := C.uiSaveFile(w.w) + name := C.GoString(cname) + freestr(cname) + return name +} + +func MsgBox(w *Window, title string, description string) { + ctitle := C.CString(title) + cdescription := C.CString(description) + C.uiMsgBox(w.w, ctitle, cdescription) + freestr(ctitle) + freestr(cdescription) +} From a8bcf1a4fab9dc59f6c786c9cc38f0800a5c9990 Mon Sep 17 00:00:00 2001 From: Vadzim Dambrouski Date: Fri, 10 Jun 2016 02:52:23 +0300 Subject: [PATCH 2/2] Using C.uiFreeText instead of freestr --- stddialogs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stddialogs.go b/stddialogs.go index f30c75f..7954512 100644 --- a/stddialogs.go +++ b/stddialogs.go @@ -17,14 +17,14 @@ func MsgBoxError(w *Window, title string, description string) { func OpenFile(w *Window) string { cname := C.uiOpenFile(w.w) name := C.GoString(cname) - freestr(cname) + C.uiFreeText(cname) return name } func SaveFile(w *Window) string { cname := C.uiSaveFile(w.w) name := C.GoString(cname) - freestr(cname) + C.uiFreeText(cname) return name }