示例#1
0
// Initialize view to reflect the model:
func (v *FilesTreeView) init(model *models.FilesTreeStore) error {
	renderer1, err := gtk.CellRendererTextNew()
	if err != nil {
		return fmt.Errorf("Error CellRendererTextNew:", err)
	}
	renderer2, err := gtk.CellRendererPixbufNew()
	if err != nil {
		return fmt.Errorf("Error CellRendererPixbufNew:", err)
	}
	col1, err := gtk.TreeViewColumnNewWithAttribute("Type", renderer2, "pixbuf", 0)
	if err != nil {
		return fmt.Errorf("Error col1:", err)
	}
	col2, err := gtk.TreeViewColumnNewWithAttribute("Name", renderer1, "text", 1)
	if err != nil {
		return fmt.Errorf("Error col2:", err)
	}
	v.view, err = gtk.TreeViewNewWithModel(model.TreeStore())
	if err != nil {
		return fmt.Errorf("Error TreeViewNew", err)
	}
	v.view.AppendColumn(col1)
	v.view.AppendColumn(col2)
	v.scrolled.Add(v.view)
	return nil
}
示例#2
0
文件: newgtk.go 项目: sqp/godock
// TreeViewWithModel creates a *gtk.TreeView.
func TreeViewWithModel(model gtk.ITreeModel) *gtk.TreeView {
	w, _ := gtk.TreeViewNewWithModel(model)
	return w
}