-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlabel_linux.go
56 lines (45 loc) · 1.06 KB
/
label_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package goey
import (
"unsafe"
"bitbucket.org/rj/goey/base"
"github.com/gotk3/gotk3/gtk"
)
type labelElement struct {
Control
}
func (w *Label) mount(parent base.Control) (base.Element, error) {
handle, err := gtk.LabelNew(w.Text)
if err != nil {
return nil, err
}
handle.SetSingleLineMode(false)
parent.Handle.Add(handle)
handle.SetJustify(gtk.JUSTIFY_LEFT)
handle.SetHAlign(gtk.ALIGN_START)
handle.SetLineWrap(false)
handle.Show()
retval := &labelElement{Control: Control{&handle.Widget}}
handle.Connect("destroy", labelOnDestroy, retval)
return retval, nil
}
func labelOnDestroy(widget *gtk.Label, mounted *labelElement) {
mounted.handle = nil
}
func (w *labelElement) label() *gtk.Label {
return (*gtk.Label)(unsafe.Pointer(w.handle))
}
func (w *labelElement) Props() base.Widget {
label := w.label()
text, err := label.GetText()
if err != nil {
panic("Could not get text, " + err.Error())
}
return &Label{
Text: text,
}
}
func (w *labelElement) updateProps(data *Label) error {
label := w.label()
label.SetText(data.Text)
return nil
}