diff options
| author | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-12-11 20:37:59 -0500 |
| commit | f8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch) | |
| tree | 82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /prev/tab_unix.go | |
| parent | e34c561ed5bedeb180437ec165882b98d70d38c1 (diff) | |
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'prev/tab_unix.go')
| -rw-r--r-- | prev/tab_unix.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/prev/tab_unix.go b/prev/tab_unix.go new file mode 100644 index 0000000..5e77b17 --- /dev/null +++ b/prev/tab_unix.go @@ -0,0 +1,51 @@ +// +build !windows,!darwin + +// 25 july 2014 + +package ui + +import ( + "unsafe" +) + +// #include "gtk_unix.h" +import "C" + +type tab struct { + *controlSingleWidget + container *C.GtkContainer + notebook *C.GtkNotebook + + tabs []*container + children []Control +} + +func newTab() Tab { + widget := C.gtk_notebook_new() + t := &tab{ + controlSingleWidget: newControlSingleWidget(widget), + container: (*C.GtkContainer)(unsafe.Pointer(widget)), + notebook: (*C.GtkNotebook)(unsafe.Pointer(widget)), + } + // 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) + return t +} + +func (t *tab) Append(name string, control Control) { + c := newContainer() + t.tabs = append(t.tabs, c) + // this calls gtk_container_add(), which, according to gregier in irc.gimp.net/#gtk+, acts just like gtk_notebook_append_page() + C.gtk_container_add(t.container, c.widget) + control.setParent(c.parent()) + c.resize = control.resize + t.children = append(t.children, control) + cname := togstr(name) + defer freegstr(cname) + 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) +} + +// no need to handle resize; the children containers handle that for us |
