Example #1
0
func rowActivated(model *gtk3.TreeStore,
	treeView *gtk3.TreeView, path *gtk3.TreePath,
	column *gtk3.TreeViewColumn, data ...interface{}) {

	var iter gtk3.TreeIter
	var call func(gtk3.WidgetLike) gtk3.WidgetLike

	model.GetIter(&iter, path)
	style := model.GetValue(&iter, StyleColumn).(int)

	indices := path.GetIndices()
	if len(indices) > 1 {
		call = Demos[indices[0]].Children[indices[1]].CallBack
	} else {
		call = Demos[indices[0]].CallBack
	}

	if call != nil {
		if style == pango.PangoStyle.ITALIC {
			style = pango.PangoStyle.NORMAL
		} else {
			style = pango.PangoStyle.ITALIC
		}
		model.SetValue(&iter, StyleColumn, style)
		window := call(treeView.GetTopLevel())

		if window != nil {
			window.Connect("destroy", windowClosed, model, path.Copy())
		}
	}
}