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())
		}
	}
}
Example #2
0
func windowClosed(model *gtk3.TreeStore, path *gtk3.TreePath) {
	var iter gtk3.TreeIter

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

	if style == pango.PangoStyle.ITALIC {
		model.SetValue(&iter, StyleColumn, pango.PangoStyle.NORMAL)
	}
}
Example #3
0
func itemToggled(model *gtk3.TreeStore, column int, data ...interface{}) {
	var iter gtk3.TreeIter
	pathStr := data[1].(string)
	path := gtk3.NewTreePathFromString(pathStr)

	model.GetIter(&iter, path)
	toggleItem := model.GetValue(&iter, column).(bool)

	if toggleItem {
		toggleItem = false
	} else {
		toggleItem = true
	}

	model.SetValue(&iter, column, toggleItem)
}