summaryrefslogtreecommitdiff
path: root/redo/table_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-29 10:54:52 -0400
committerPietro Gagliardi <[email protected]>2014-07-29 10:54:52 -0400
commit8d7f0c9a62b9108e262380ae62f8c8b9cbb12bfc (patch)
treeb90dcbac59d436552494e02e302ae27e820cd8f5 /redo/table_darwin.go
parent4e0436da18ef5e8e0c4bbc1c17e5bd5932515991 (diff)
Wrote up the data model for Mac OS X Tables; now Tables work everywhere!
Diffstat (limited to 'redo/table_darwin.go')
-rw-r--r--redo/table_darwin.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/redo/table_darwin.go b/redo/table_darwin.go
index 91a57ac..206820a 100644
--- a/redo/table_darwin.go
+++ b/redo/table_darwin.go
@@ -3,7 +3,7 @@
package ui
import (
-// "fmt"
+ "fmt"
"reflect"
"unsafe"
)
@@ -26,7 +26,7 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
tablebase: b,
table: id,
}
- // TODO model
+ C.tableMakeDataSource(t.table, unsafe.Pointer(t))
for i := 0; i < ty.NumField(); i++ {
cname := C.CString(ty.Field(i).Name)
C.tableAppendColumn(t.table, cname)
@@ -43,3 +43,23 @@ func (t *table) Unlock() {
defer t.RUnlock()
C.tableUpdate(t.table)
}
+
+//export goTableDataSource_getValue
+func goTableDataSource_getValue(data unsafe.Pointer, row C.intptr_t, col C.intptr_t) *C.char {
+ t := (*table)(data)
+ t.RLock()
+ defer t.RUnlock()
+ d := reflect.Indirect(reflect.ValueOf(t.data))
+ datum := d.Index(int(row)).Field(int(col))
+ s := fmt.Sprintf("%v", datum)
+ return C.CString(s)
+}
+
+//export goTableDataSource_getRowCount
+func goTableDataSource_getRowCount(data unsafe.Pointer) C.intptr_t {
+ t := (*table)(data)
+ t.RLock()
+ defer t.RUnlock()
+ d := reflect.Indirect(reflect.ValueOf(t.data))
+ return C.intptr_t(d.Len())
+}