-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatusbar.go
55 lines (41 loc) · 895 Bytes
/
statusbar.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
package main
import (
"log"
"github.com/gotk3/gotk3/gtk"
)
type (
statusbar struct {
app *app
gtkStatusBar *gtk.Statusbar
}
)
func newStatusbar(app *app) *statusbar {
// Define statusbar
gtkstatusBar, err := gtk.StatusbarNew()
if err != nil {
log.Fatal("failed setting up gtk statusbar: ", err)
}
msgArea, _ := gtkstatusBar.GetMessageArea()
msgArea.SetHAlign(gtk.ALIGN_END)
return &statusbar{
app: app,
gtkStatusBar: gtkstatusBar,
}
}
func (s *statusbar) SetText(text string) {
s.gtkStatusBar.Push(s.gtkStatusBar.GetContextId("textView cursor position"), text)
}
func (s *statusbar) Show() {
if s.app == nil || s.app.grid == nil {
return
}
s.app.grid.Add(s.gtkStatusBar)
s.app.grid.ShowAll()
}
func (s *statusbar) Hide() {
if s.app == nil || s.app.grid == nil {
return
}
s.app.grid.Remove(s.gtkStatusBar)
s.app.grid.ShowAll()
}