Exemplo n.º 1
0
func attachWidgets(textView *gtk3.TextView) {
	var iter gtk3.TextIter

	buffer := textView.GetBuffer()
	buffer.GetStartIter(&iter)

	i := 0
	var widget gtk3.WidgetLike
	for findAnchor(&iter) {
		anchor := iter.GetChildAnchor()

		switch i {
		case 0:
			widget = gtk3.NewButtonWithLabel("Click Me")
			//widget.Connect("clicked",
		case 1:
			combo := gtk3.NewComboBoxText()
			combo.AppendText("Option 1")
			combo.AppendText("Option 2")
			combo.AppendText("Option 3")
			widget = combo
		case 2:
			filename, _ := findFile("floppybuddy.gif")
			widget = gtk3.NewImageFromFile(filename)
		case 3:
			widget = gtk3.NewEntry()
		default:
			break
		}
		textView.AddChildAtAnchor(widget, anchor)
		widget.W().ShowAll()
		i++
	}
}
Exemplo n.º 2
0
func findAnchor(iter *gtk3.TextIter) bool {
	for iter.ForwardChar() {
		if iter.GetChildAnchor() != nil {
			return true
		}
	}
	return false
}