예제 #1
0
파일: table_unix.go 프로젝트: NotBadPad/ui
func (t *table) Select(index int) {
	t.RLock()
	defer t.RUnlock()
	C.gtk_tree_selection_unselect_all(t.selection)
	if index == -1 {
		return
	}
	path := C.gtk_tree_path_new()
	defer C.gtk_tree_path_free(path)
	C.gtk_tree_path_append_index(path, C.gint(index))
	C.gtk_tree_selection_select_path(t.selection, path)
}
예제 #2
0
파일: table_unix.go 프로젝트: NotBadPad/ui
func (t *table) Selected() int {
	var iter C.GtkTreeIter

	t.RLock()
	defer t.RUnlock()
	if C.gtk_tree_selection_get_selected(t.selection, nil, &iter) == C.FALSE {
		return -1
	}
	path := C.gtk_tree_model_get_path(t.modelgtk, &iter)
	if path == nil {
		panic(fmt.Errorf("invalid iter in Table.Selected()"))
	}
	defer C.gtk_tree_path_free(path)
	return int(*C.gtk_tree_path_get_indices(path))
}