2020-07-14 07:24:55 +00:00
|
|
|
package singlestack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gotk3/gotk3/gtk"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Stack struct {
|
|
|
|
*gtk.Stack
|
|
|
|
current gtk.IWidget
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewStack() *Stack {
|
|
|
|
stack, _ := gtk.StackNew()
|
|
|
|
return &Stack{stack, nil}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stack) Add(w gtk.IWidget) {
|
|
|
|
if s.current == w {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-10-23 06:16:45 +00:00
|
|
|
if s.current != nil {
|
|
|
|
s.Stack.Remove(s.current)
|
|
|
|
}
|
|
|
|
|
2020-07-14 07:24:55 +00:00
|
|
|
if w != nil {
|
|
|
|
s.Stack.Add(w)
|
|
|
|
s.Stack.SetVisibleChild(w)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.current = w
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stack) SetVisibleChild(w gtk.IWidget) {
|
|
|
|
s.Add(w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Stack) GetChild() (gtk.IWidget, error) {
|
|
|
|
return s.current, nil
|
|
|
|
}
|