summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bleh_darwin.m5
-rw-r--r--objc_darwin.h1
-rw-r--r--sysdata_darwin.go32
-rw-r--r--todo.md1
4 files changed, 37 insertions, 2 deletions
diff --git a/bleh_darwin.m b/bleh_darwin.m
index 80896ef..1b58e77 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -36,6 +36,11 @@ id objc_msgSend_int(id obj, SEL sel, intptr_t a)
return objc_msgSend(obj, sel, (NSInteger) a);
}
+id objc_msgSend_id_int(id obj, SEL sel, id a, intptr_t b)
+{
+ return objc_msgSend(obj, sel, a, (NSInteger) b);
+}
+
/*
These are the objc_msgSend() wrappers around NSRect. The problem is that while on 32-bit systems, NSRect is a concrete structure, on 64-bit systems it's just a typedef to CGRect. While in practice just using CGRect everywhere seems to work, better to be safe than sorry.
diff --git a/objc_darwin.h b/objc_darwin.h
index 5d6bd41..e02f41e 100644
--- a/objc_darwin.h
+++ b/objc_darwin.h
@@ -79,6 +79,7 @@ extern id objc_msgSend_int(id obj, SEL sel, intptr_t a);
m2(id_id, id, id)
extern id _objc_msgSend_rect_bool(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h, BOOL b);
+extern id objc_msgSend_id_int(id obj, SEL sel, id a, intptr_t b);
m3(id_id_id, id, id, id)
m3(sel_id_bool, SEL, id, BOOL)
diff --git a/sysdata_darwin.go b/sysdata_darwin.go
index 311827e..88d9ddb 100644
--- a/sysdata_darwin.go
+++ b/sysdata_darwin.go
@@ -25,6 +25,9 @@ type classData struct {
textsel C.SEL
alttextsel C.SEL
append func(id C.id, what string, alternate bool)
+ insertBefore func(id C.id, what string, before int, alternate bool)
+ // TODO others
+ delete func(id C.id, index int)
}
var (
@@ -169,6 +172,17 @@ var classTypes = [nctypes]*classData{
C.objc_msgSend_id(id, _addItemWithTitle, str)
}
},
+ insertBefore: func(id C.id, what string, before int, alternate bool) {
+ str := toNSString(what)
+ if alternate {
+ C.objc_msgSend_id_int(id, _insertItemWithObjectValueAtIndex, str, C.intptr_t(before))
+ } else {
+ C.objc_msgSend_id_int(id, _insertItemWithTitleAtIndex, str, C.intptr_t(before))
+ }
+ },
+ delete: func(id C.id, index int) {
+ C.objc_msgSend_int(id, _removeItemAtIndex, C.intptr_t(index))
+ },
},
c_lineedit: &classData{
},
@@ -315,7 +329,14 @@ if classTypes[s.ctype].append == nil { return nil }
}
func (s *sysData) insertBefore(what string, before int) error {
- // TODO
+if classTypes[s.ctype].insertBefore == nil { return nil }
+ ret := make(chan struct{})
+ defer close(ret)
+ uitask <- func() {
+ classTypes[s.ctype].insertBefore(s.id, what, before, s.alternate)
+ ret <- struct{}{}
+ }
+ <-ret
return nil
}
@@ -350,7 +371,14 @@ func (s *sysData) setWindowSize(width int, height int) error {
}
func (s *sysData) delete(index int) error {
- // TODO
+if classTypes[s.ctype].delete == nil { return nil }
+ ret := make(chan struct{})
+ defer close(ret)
+ uitask <- func() {
+ classTypes[s.ctype].delete(s.id, index)
+ ret <- struct{}{}
+ }
+ <-ret
return nil
}
diff --git a/todo.md b/todo.md
index 883d951..bac231e 100644
--- a/todo.md
+++ b/todo.md
@@ -28,6 +28,7 @@ important things:
- Cocoa coordinates have (0,0) at the bottom left: need to fix this somehow
- I think Cocoa NSButton text is not vertically aligned properly...?
- resizing Cocoa windows does not redraw controls correctly
+- figure out what to do about deleting a nonexistent item; each backend responds differently by default
- there's no GTK+ error handling whatsoever; we need to figure out how it works
- make sure GTK+ documentation point differences don't matter
- button sizes and LineEdit sizes on Windows seem too big; Comboboxes have margins