summaryrefslogtreecommitdiff
path: root/redo/textfield_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-20 01:35:05 -0400
committerPietro Gagliardi <[email protected]>2014-08-20 01:35:05 -0400
commitac1b8e3cca971c38c8091f60fedfe093e6fe78df (patch)
tree746ec1b161084b775b7e1260335f02eae9731210 /redo/textfield_unix.go
parent5f830deec8374336d1d268a27e41f5ec492c866c (diff)
Added a test for TextField.Invalid() and implemented it on the GTK+ backend.
Diffstat (limited to 'redo/textfield_unix.go')
-rw-r--r--redo/textfield_unix.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/redo/textfield_unix.go b/redo/textfield_unix.go
index c4ce8b4..e9624ee 100644
--- a/redo/textfield_unix.go
+++ b/redo/textfield_unix.go
@@ -10,6 +10,11 @@ import (
// #include "gtk_unix.h"
// extern void textfieldChanged(GtkEditable *, gpointer);
+// /* because cgo doesn't like GTK_STOCK_DIALOG_ERROR */
+// static inline void setErrorIcon(GtkEntry *entry)
+// {
+// gtk_entry_set_icon_from_stock(entry, GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIALOG_ERROR);
+// }
import "C"
type textfield struct {
@@ -58,7 +63,14 @@ func (t *textfield) OnChanged(f func()) {
}
func (t *textfield) Invalid(reason string) {
- // TODO
+ if reason == "" {
+ C.gtk_entry_set_icon_from_stock(t.entry, C.GTK_ENTRY_ICON_SECONDARY, nil)
+ return
+ }
+ C.setErrorIcon(t.entry)
+ creason := togstr(reason)
+ defer freegstr(creason)
+ C.gtk_entry_set_icon_tooltip_text(t.entry, C.GTK_ENTRY_ICON_SECONDARY, creason)
}
//export textfieldChanged