Skip to content

Commit 9afceff

Browse files
committed
dropped pkg dir, more readme bits
1 parent 33cf3fc commit 9afceff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+95
-96
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Jeff Lindsay
3+
Copyright (c) 2020 Jeff Lindsay, Mikkel Krautz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://github.com/progrium/macdriver/raw/main/macdriver.gif" alt="MacDriver Logo">
22

3-
Native Mac APIs for Go!
3+
Native Mac APIs for Golang!
44

55
[![GoDoc](https://godoc.org/github.com/progrium/macdriver?status.svg)](https://godoc.org/github.com/progrium/macdriver)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/progrium/macdriver)](https://goreportcard.com/report/github.com/progrium/macdriver)
@@ -9,23 +9,22 @@ Native Mac APIs for Go!
99

1010
------
1111

12-
MacDriver is a toolkit for working with Apple/Mac APIs and frameworks. It currently has 3 major components:
12+
MacDriver is a toolkit for working with Apple/Mac APIs and frameworks in Go. It currently has 3 major "layers":
1313

14-
## Bindings for libobjc
14+
## Bindings for Objective-C
1515
The `objc` package wraps the [Objective-C runtime](https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc) to dynamically interact with Objective-C objects and classes:
1616

17-
```go
18-
objc.Get("NSApplication").Get("sharedApplication").Send("terminate:", nil)
19-
```
20-
21-
Also dynamically create them:
22-
2317
```go
2418
cls := objc.NewClass("AppDelegate", "NSObject")
2519
cls.AddMethod("applicationDidFinishLaunching:", func(app objc.Object) {
2620
fmt.Println("Launched!")
2721
})
2822
objc.RegisterClass(cls)
23+
24+
delegate := objc.Get("AppDelegate").Alloc().Init()
25+
app := objc.Get("NSApplication").Get("sharedApplication")
26+
app.Set("delegate:", delegate)
27+
app.Send("run")
2928
```
3029

3130
## Framework Packages
@@ -35,6 +34,7 @@ we can automate this process with schema data. These packages effectively let yo
3534
```go
3635
w := cocoa.NSWindow_Init(core.Rect(0, 0, 1440, 900),
3736
cocoa.NSTitledWindowMask, cocoa.NSBackingStoreBuffered, false)
37+
w.SetBackgroundColor(cocoa.NSColor_Clear())
3838
w.MakeKeyAndOrderFront(w)
3939
```
4040

@@ -71,16 +71,16 @@ screen with HTML/JS:
7171
![topframe screenshot](https://pbs.twimg.com/media/EqhYDmlW8AEBC6-?format=jpg&name=large)
7272

7373
## Bridge System
74-
Lastly, a common use case for this toolkit is not building full native apps, but integrating Go applications
75-
with various Mac systems, like windows, native menus, status icons (systray), etc.
74+
Lastly, a common case for this toolkit is not just building full native apps, but integrating Go applications
75+
with Mac systems, like windows, native menus, status icons (systray), etc.
7676
One-off libraries for some of these exist, but besides often limiting what you can do,
7777
they're also just not composable. They all want to own the main thread!
7878

7979
For this and other reasons, we often run the above kind of code in a separate process altogether from our
8080
Go application. This might seem like a step backwards, but it is safer and more robust in a way.
8181

8282
The `bridge` package takes advantage of this situation to create a higher-level abstraction more aligned with a potential
83-
cross-platform toolkit where you can declaratively describe and modify structs that can be copied to the bridge process and applied to the Objective-C
83+
cross-platform toolkit. You can declaratively describe and modify structs that can be copied to the bridge process and applied to the Objective-C
8484
objects in a manner similar to configuration management:
8585

8686
```go
@@ -89,7 +89,7 @@ package main
8989
import (
9090
"os"
9191

92-
"github.com/progrium/macdriver/pkg/bridge"
92+
"github.com/progrium/macdriver/bridge"
9393
)
9494

9595
func main() {
@@ -138,8 +138,7 @@ as needed until we have enough coverage/confidence to know how we'd generate wra
138138

139139
## Thanks
140140

141-
The original `objc` and `variadic` packages were written by Mikkel Krautz. The `variadic` package is a little magic to make everything possible since
142-
libobjc relies heavily on variadic function calls, which aren't possible out of the box in Cgo.
141+
The original `objc` and `variadic` packages were written by [Mikkel Krautz](https://github.com/mkrautz). The `variadic` package is some assembly magic to make everything possible since libobjc relies heavily on variadic function calls, which aren't possible out of the box in Cgo.
143142

144143
## License
145144

pkg/bridge/bridge.go renamed to bridge/bridge.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414
"github.com/manifold/qtalk/golang/mux"
1515
"github.com/manifold/qtalk/golang/rpc"
1616
"github.com/mitchellh/mapstructure"
17-
"github.com/progrium/macdriver/pkg/cocoa"
18-
"github.com/progrium/macdriver/pkg/core"
19-
"github.com/progrium/macdriver/pkg/objc"
17+
"github.com/progrium/macdriver/cocoa"
18+
"github.com/progrium/macdriver/core"
19+
"github.com/progrium/macdriver/objc"
2020
)
2121

2222
var (
File renamed without changes.

pkg/bridge/menu.go renamed to bridge/menu.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"reflect"
88

99
"github.com/manifold/qtalk/golang/rpc"
10-
"github.com/progrium/macdriver/pkg/cocoa"
11-
"github.com/progrium/macdriver/pkg/core"
12-
"github.com/progrium/macdriver/pkg/objc"
10+
"github.com/progrium/macdriver/cocoa"
11+
"github.com/progrium/macdriver/core"
12+
"github.com/progrium/macdriver/objc"
1313
"github.com/rs/xid"
1414
)
1515

pkg/bridge/misc.go renamed to bridge/misc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package bridge
22

33
import (
4-
"github.com/progrium/macdriver/pkg/cocoa"
5-
"github.com/progrium/macdriver/pkg/core"
4+
"github.com/progrium/macdriver/cocoa"
5+
"github.com/progrium/macdriver/core"
66
)
77

88
type Point struct {

pkg/bridge/resource.go renamed to bridge/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77

88
"github.com/manifold/qtalk/golang/rpc"
9-
"github.com/progrium/macdriver/pkg/objc"
9+
"github.com/progrium/macdriver/objc"
1010
"github.com/rs/xid"
1111
)
1212

pkg/bridge/systray.go renamed to bridge/systray.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"encoding/base64"
55
"reflect"
66

7-
"github.com/progrium/macdriver/pkg/cocoa"
8-
"github.com/progrium/macdriver/pkg/core"
9-
"github.com/progrium/macdriver/pkg/objc"
7+
"github.com/progrium/macdriver/cocoa"
8+
"github.com/progrium/macdriver/core"
9+
"github.com/progrium/macdriver/objc"
1010
)
1111

1212
type StatusItem struct {

pkg/bridge/window.go renamed to bridge/window.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"encoding/base64"
55
"reflect"
66

7-
"github.com/progrium/macdriver/pkg/cocoa"
8-
"github.com/progrium/macdriver/pkg/core"
9-
"github.com/progrium/macdriver/pkg/objc"
10-
"github.com/progrium/macdriver/pkg/webkit"
7+
"github.com/progrium/macdriver/cocoa"
8+
"github.com/progrium/macdriver/core"
9+
"github.com/progrium/macdriver/objc"
10+
"github.com/progrium/macdriver/webkit"
1111
)
1212

1313
type Window struct {

cmd/macbridge/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"runtime"
55

6-
"github.com/progrium/macdriver/pkg/bridge"
6+
"github.com/progrium/macdriver/bridge"
77
)
88

99
func main() {

0 commit comments

Comments
 (0)