2014-07-25 22:11:41 -05:00
|
|
|
// +build !windows,!darwin
|
|
|
|
|
2014-07-25 19:47:08 -05:00
|
|
|
// 25 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "gtk_unix.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type tab struct {
|
2014-08-03 15:28:21 -05:00
|
|
|
_widget *C.GtkWidget
|
2014-08-04 21:21:58 -05:00
|
|
|
container *C.GtkContainer
|
2014-07-25 19:47:08 -05:00
|
|
|
notebook *C.GtkNotebook
|
|
|
|
|
2014-08-04 20:08:18 -05:00
|
|
|
tabs []*container
|
2014-07-25 19:47:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func newTab() Tab {
|
|
|
|
widget := C.gtk_notebook_new()
|
|
|
|
t := &tab{
|
2014-08-03 15:28:21 -05:00
|
|
|
_widget: widget,
|
2014-08-04 21:21:58 -05:00
|
|
|
container: (*C.GtkContainer)(unsafe.Pointer(widget)),
|
2014-07-25 19:47:08 -05:00
|
|
|
notebook: (*C.GtkNotebook)(unsafe.Pointer(widget)),
|
|
|
|
}
|
2014-07-28 12:18:03 -05:00
|
|
|
// there are no scrolling arrows by default; add them in case there are too many tabs
|
|
|
|
C.gtk_notebook_set_scrollable(t.notebook, C.TRUE)
|
2014-07-25 19:47:08 -05:00
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) Append(name string, control Control) {
|
2014-08-04 20:08:18 -05:00
|
|
|
c := newContainer(control)
|
|
|
|
t.tabs = append(t.tabs, c)
|
2014-08-04 21:21:58 -05:00
|
|
|
// this calls gtk_container_add(), which, according to gregier in irc.gimp.net/#gtk+, acts just like gtk_notebook_append_page()
|
|
|
|
c.setParent(&controlParent{t.container})
|
2014-07-25 19:47:08 -05:00
|
|
|
cname := togstr(name)
|
|
|
|
defer freegstr(cname)
|
2014-08-04 21:21:58 -05:00
|
|
|
C.gtk_notebook_set_tab_label_text(t.notebook,
|
|
|
|
// unfortunately there does not seem to be a gtk_notebook_set_nth_tab_label_text()
|
|
|
|
C.gtk_notebook_get_nth_page(t.notebook, C.gint(len(t.tabs) - 1)),
|
|
|
|
cname)
|
2014-07-25 19:47:08 -05:00
|
|
|
}
|
|
|
|
|
2014-08-03 15:28:21 -05:00
|
|
|
func (t *tab) widget() *C.GtkWidget {
|
|
|
|
return t._widget
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) setParent(p *controlParent) {
|
|
|
|
basesetParent(t, p)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
|
|
|
return baseallocate(t, x, y, width, height, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) preferredSize(d *sizing) (width, height int) {
|
|
|
|
return basepreferredSize(t, d)
|
|
|
|
}
|
|
|
|
|
2014-08-02 00:14:09 -05:00
|
|
|
// no need to override Control.commitResize() as only prepared the tabbed control; its children will be reallocated when that one is resized
|
2014-08-03 15:28:21 -05:00
|
|
|
func (t *tab) commitResize(a *allocation, d *sizing) {
|
|
|
|
basecommitResize(t, a, d)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *tab) getAuxResizeInfo(d *sizing) {
|
2014-08-03 19:33:19 -05:00
|
|
|
basegetAuxResizeInfo(t, d)
|
2014-08-03 15:28:21 -05:00
|
|
|
}
|