Пример #1
0
func newStackFull() gtk.IWidget {
	// get a stack and its switcher.
	stack, err := gtk.StackNew()
	if err != nil {
		log.Fatal("Unable to get text:", err)
	}

	sw, err := gtk.StackSwitcherNew()
	if err != nil {
		log.Fatal("Unable to get text:", err)
	}
	sw.SetStack(stack)

	// Fill the stack with 3 pages.
	boxText1 := newBoxText("Hello there!")
	boxRadio := newBoxRadio("choice 1", "choice 2", "choice 3", "choice 42")
	boxText2 := newBoxText("third page")

	stack.AddTitled(boxText1, "key1", "first page")
	stack.AddTitled(boxRadio, "key2", "second page")
	stack.AddTitled(boxText2, "key3", "third page")

	// You can use icons for a switcher page (the page title will be visible as tooltip).
	stack.ChildSetProperty(boxRadio, "icon-name", "list-add")

	// Pack in a box.
	box := setup_box(gtk.ORIENTATION_VERTICAL)
	box.PackStart(sw, false, false, 0)
	box.PackStart(stack, true, true, 0)
	return box
}
Пример #2
0
func GraphViewCollectionNew(width, height int) (gvc *graphViewCollection, err error) {
	gvc = &graphViewCollection{}
	gvc.gmap = make(map[string]GraphViewIf)
	gvc.box, err = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	if err != nil {
		err = fmt.Errorf("GraphViewCollectionNew: Unable to create box:", err)
		return
	}
	gvc.header, err = gtk.HeaderBarNew()
	if err != nil {
		err = fmt.Errorf("GraphViewCollectionNew: Unable to create bar:", err)
		return
	}
	gvc.tabs, err = gtk.StackSwitcherNew()
	if err != nil {
		err = fmt.Errorf("GraphViewCollectionNew: Unable to create stackswitcher:", err)
		return
	}
	gvc.stack, err = gtk.StackNew()
	if err != nil {
		err = fmt.Errorf("GraphViewCollectionNew: Unable to create Stack:", err)
		return
	}
	gvc.box.PackStart(gvc.header, false, true, 0)
	gvc.header.Add(gvc.tabs)
	gvc.tabs.SetStack(gvc.stack)
	gvc.box.Add(gvc.stack)

	gvc.xmlview, err = XmlTextViewNew(width, height)
	if err != nil {
		err = fmt.Errorf("GraphViewCollectionNew: Could not create XML view.")
		return
	}
	gvc.stack.AddTitled(gvc.xmlview.Widget(), "XML View", "XML View")
	return
}
Пример #3
0
// StackSwitcher creates a *gtk.StackSwitcher.
func StackSwitcher() *gtk.StackSwitcher {
	w, _ := gtk.StackSwitcherNew()
	return w
}