예제 #1
0
파일: listbox_unix.go 프로젝트: UIKit0/ui
func gListboxSelMultiTexts(widget *C.GtkWidget) (texts []string) {
	var model *C.GtkTreeModel
	var iter C.GtkTreeIter
	var gs *C.gchar

	tv := getTreeViewFrom(widget)
	sel := C.gtk_tree_view_get_selection(tv)
	rows := C.gtk_tree_selection_get_selected_rows(sel, &model)
	defer C.g_list_free_full(rows, C.GDestroyNotify(unsafe.Pointer(C.gtk_tree_path_free)))
	len := C.g_list_length(rows)
	if len == 0 {
		return nil
	}
	texts = make([]string, len)
	for i := C.guint(0); i < len; i++ {
		path := (*C.GtkTreePath)(unsafe.Pointer(rows.data))
		if C.gtk_tree_model_get_iter(model, &iter, path) == C.FALSE {
			panic("gtk_tree_model_get_iter() failed getting Listbox selected texts; reason unknown")
		}
		C.gtkTreeModelGet(model, &iter, &gs)
		texts[i] = fromgstr(gs)
		rows = rows.next
	}
	return texts
}
예제 #2
0
파일: lib.go 프로젝트: cfstras/cfmedias
func (g *glib) Tracks() []Track {
	ptr := g.db.tracks
	len := C.g_list_length(ptr)
	arr := make([]Track, 0, len)
	for ptr != nil {
		track := newTrack(g, (*C.Itdb_Track)(ptr.data), false)
		arr = append(arr, track)
		ptr = ptr.next
	}
	return arr
}
예제 #3
0
파일: udev.go 프로젝트: sergiusens/godd
func (c *Client) QueryBySubsystem(subsystem string) []Device {
	l := C.g_udev_client_query_by_subsystem(c.p, (*C.gchar)(C.CString(subsystem)))
	result := make([]Device, C.g_list_length(l))
	for i := range result {
		p := (*C.struct__GUdevDevice)(l.data)
		device := Device{
			p: p,
		}
		runtime.SetFinalizer(&device, func(device *Device) {
			C.g_object_unref((C.gpointer)(device.p))
		})
		result[i] = device
		l = l.next
	}
	C.g_list_free(l)

	return result
}
예제 #4
0
파일: listbox_unix.go 프로젝트: UIKit0/ui
func gListboxSelectedMulti(widget *C.GtkWidget) (indices []int) {
	var model *C.GtkTreeModel

	tv := getTreeViewFrom(widget)
	sel := C.gtk_tree_view_get_selection(tv)
	rows := C.gtk_tree_selection_get_selected_rows(sel, &model)
	defer C.g_list_free_full(rows, C.GDestroyNotify(unsafe.Pointer(C.gtk_tree_path_free)))
	// g_list_length() is O(N), but we need the length below, alas
	len := C.g_list_length(rows)
	if len == 0 {
		return nil
	}
	indices = make([]int, len)
	for i := C.guint(0); i < len; i++ {
		path := (*C.GtkTreePath)(unsafe.Pointer(rows.data))
		idx := C.gtk_tree_path_get_indices(path)
		indices[i] = int(*idx)
		rows = rows.next
	}
	return indices
}
예제 #5
0
파일: glib.go 프로젝트: leif/go-gtk
func (v List) Length() uint {
	return uint(C.g_list_length(v.GList))
}
예제 #6
0
파일: glib.go 프로젝트: pauldub/go-gtk3
func (self *GList) Length() uint {
	return uint(C.g_list_length(self.object))
}
예제 #7
0
파일: glib.go 프로젝트: LittleBuster/gotk3
// Length is a wrapper around g_list_length().
func (v *List) Length() uint {
	glist := (*C.GList)(unsafe.Pointer(v))
	return uint(C.g_list_length(glist))
}