Пример #1
0
func gListboxText(widget *C.GtkWidget) string {
	var model *C.GtkTreeModel
	var iter C.GtkTreeIter
	var gs *C.gchar

	tv := getTreeViewFrom(widget)
	sel := C.gtk_tree_view_get_selection(tv)
	if !fromgbool(C.gtk_tree_selection_get_selected(sel, &model, &iter)) {
		return ""
	}
	C.gtkTreeModelGet(model, &iter, &gs)
	return fromgstr(gs)
}
Пример #2
0
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))
}