Compare commits
44 Commits
main
...
gtk4-swift
Author | SHA1 | Date |
---|---|---|
![]() |
b74dc77093 | |
![]() |
a2c87fffdc | |
![]() |
bb8a8b482c | |
![]() |
0d548b2770 | |
![]() |
d2a91269d7 | |
![]() |
18dfecfb72 | |
![]() |
4341d955fe | |
![]() |
9d36b9a3a2 | |
![]() |
280eb57fe2 | |
![]() |
434557d985 | |
![]() |
5c66a3b697 | |
![]() |
b88a5fa75e | |
![]() |
681ce7c762 | |
![]() |
f6358ff6a1 | |
![]() |
4556e6a1cb | |
![]() |
c8e02d8e82 | |
![]() |
1d79c033df | |
![]() |
e5dc13f81a | |
![]() |
04fae99989 | |
![]() |
b2748cf993 | |
![]() |
5b08198f7c | |
![]() |
be0061a24d | |
![]() |
4b10f39c7b | |
![]() |
840814bcab | |
![]() |
9207c22c1d | |
![]() |
0ccefaaf30 | |
![]() |
b735367bea | |
![]() |
8aa51ac16a | |
![]() |
cd0020c8e5 | |
![]() |
fe601105d9 | |
![]() |
9b6075b2b1 | |
![]() |
fe855f14d7 | |
![]() |
d7e6f6fa71 | |
![]() |
9b5706579c | |
![]() |
4b0f02c204 | |
![]() |
e142850e49 | |
![]() |
670e775bc6 | |
![]() |
73dc6e639c | |
![]() |
5da6aab77c | |
![]() |
0c4ddc932f | |
![]() |
46dc1273a8 | |
![]() |
f6271a136c | |
![]() |
7950d45d26 | |
![]() |
3f9ecf8e9f |
|
@ -7,10 +7,12 @@ env:
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
|
@ -32,7 +34,6 @@ jobs:
|
|||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: swift52
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
|
@ -60,3 +61,11 @@ jobs:
|
|||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
||||
|
||||
- name: 'Upload Artefact'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-artefact-big-sur
|
||||
path: |
|
||||
SwiftGdk/Sources/
|
||||
retention-days: 1
|
||||
|
|
|
@ -19,11 +19,6 @@ jobs:
|
|||
build-ubuntu-18_04-swift-latest:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: YOCKOW/Action-setup-swift@v1
|
||||
with:
|
||||
swift-version: '5.6.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
|
@ -38,16 +33,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -7,10 +7,12 @@ env:
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- swift52
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
|
@ -32,7 +34,6 @@ jobs:
|
|||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: swift52
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
|
@ -60,3 +61,11 @@ jobs:
|
|||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
||||
|
||||
- name: 'Upload Artefact'
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-artefact-catalina
|
||||
path: |
|
||||
SwiftGdk/Sources/
|
||||
retention-days: 1
|
||||
|
|
|
@ -19,11 +19,6 @@ jobs:
|
|||
build-ubuntu-20_04-swift-latest:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: YOCKOW/Action-setup-swift@v1
|
||||
with:
|
||||
swift-version: '5.6.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
|
@ -38,16 +33,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -17,13 +17,13 @@ on:
|
|||
jobs:
|
||||
# macOS tasks
|
||||
build-mac-gtk4-swift-latest:
|
||||
runs-on: macos-12.0
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '13.3'
|
||||
xcode-version: '13.2.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
@ -44,16 +44,23 @@ jobs:
|
|||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build Swift Wrappers
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
echo "GIR2SWIFT_PATH=${PWD}/checkouts/gir2swift/.build/release/gir2swift" >> $GITHUB_ENV
|
||||
cd ..
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
swift build -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
swift test -Xswiftc -suppress-warnings `./run-gir2swift.sh flags -noUpdate`
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
name: macOS 12
|
||||
|
||||
# Dependencies of this package
|
||||
env:
|
||||
MACOS_BREW: ${{ 'gtk+3 pango glib glib-networking gobject-introspection pkg-config jq' }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- development
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- development
|
||||
- main
|
||||
|
||||
jobs:
|
||||
# macOS tasks
|
||||
build-mac-monterey-latest:
|
||||
runs-on: macos-12.0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: '13.3.1'
|
||||
|
||||
- name: Print Swift version to confirm
|
||||
run: swift --version
|
||||
|
||||
- name: Fetch dependencies for general repository
|
||||
run: brew install $MACOS_BREW
|
||||
|
||||
- name: Checkout SwiftGdk
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: SwiftGdk
|
||||
|
||||
- name: Build SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift build
|
||||
cd ..
|
||||
|
||||
- name: Test SwiftGdk
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift test
|
||||
cd ..
|
||||
|
||||
- name: Remove unneeded files and archive artefacts
|
||||
run: |
|
||||
cd SwiftGdk
|
||||
swift package clean
|
||||
rm -rf .build/repositories
|
||||
cd ..
|
19
Gdk-3.0.sed
19
Gdk-3.0.sed
|
@ -1,19 +0,0 @@
|
|||
s/-> GdkAtom {/-> GdkAtom! {/g
|
||||
s/: GdkAtom/: GdkAtom!/g
|
||||
s/UnsafeMutablePointer<GdkAtom>/GdkAtom/
|
||||
s/targets: UnsafePointer<GdkAtom>/targets: UnsafePointer<GdkAtom?>/
|
||||
s/GdkAtom!.self/_GdkAtom.self/
|
||||
s/actual_property_type: AtomT/actual_property_type: UnsafeMutablePointer<GdkAtom?>/
|
||||
s/Xproperty: GdkAtom!, type: GdkAtom!/property: AtomT!, type: AtomT!/
|
||||
s/\(propertyGet.*\)window: WindowT, property: AtomT!, type: AtomT!/\1window: WindowT, property: UnsafeMutablePointer<GdkAtom?>, type: AtomT!/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol, WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propType: AtomT/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol>(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propType: AtomT, propFormat: UnsafeMutablePointer<gint>!) -> Int/selectionPropertyGet(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>, propertyFormat: UnsafeMutablePointer<gint>!) -> Int/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propFormat/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, property _ptr: UnsafeMutablePointer<GdkAtom?>, propertyFormat/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propertyType: UnsafeMutablePointer<GdkAtom.>!, propFormat:/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!, propertyFormat:/
|
||||
s/targets: GdkAtom/targets: UnsafePointer<GdkAtom?>/
|
||||
s/gdk_selection_property_get(requestor.window_ptr, data, propType._ptr, propFormat)/gdk_selection_property_get(requestor.window_ptr, data, propertyType, propertyFormat)/
|
||||
s/gdk_selection_property_get(window_ptr, data, propType._ptr, propFormat)/gdk_selection_property_get(window_ptr, data, propertyType, propertyFormat)/
|
||||
s/gdk_selection_property_get(requestor.window_ptr, data, _ptr, propFormat)/gdk_selection_property_get(requestor.window_ptr, data, _ptr, propertyFormat)/
|
||||
s/\(@available(., deprecated) @inlinable\) \(public init() {\)/\1 override \2/
|
||||
s/gdk_gl_context_set_use_es(gl_context_ptr, gint(newValue))/gdk_gl_context_set_use_es(gl_context_ptr, newValue ? 1 : 0)/
|
||||
s/_ptr.pointee.state = newValue.value/_ptr.pointee.state = newValue.rawValue/
|
|
@ -9,7 +9,7 @@ import GIO
|
|||
import Pango
|
||||
import Cairo
|
||||
import PangoCairo
|
||||
import GdkPixBuf
|
||||
import GdkPixbuf
|
||||
|
||||
// missing header file type aliases
|
||||
public typealias GdkXEvent = _GdkXEvent
|
|
@ -9,5 +9,5 @@ import GIO
|
|||
import Pango
|
||||
import Cairo
|
||||
import PangoCairo
|
||||
import GdkPixBuf
|
||||
import GdkPixbuf
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
s/EVENT_STOP: Bool = 5/EVENT_STOP: gboolean = 1/
|
||||
s/gdk_cursor_ref/g_object_ref/g
|
||||
s/gdk_cursor_unref/g_object_unref/g
|
||||
s/createSimilarImageSurface(format: CInt/createSimilarImageSurface(format: cairo_format_t/
|
||||
s/\(@available(., deprecated) @inlinable\) \(public init() {\)/\1 override \2/
|
||||
s/\(public init<T: AppLaunchContextProtocol>(\)appLaunchContext \(other: T)\)/\1_ \2/
|
||||
s/-> GdkAtom {/-> GdkAtom! {/g
|
||||
s/: GdkAtom/: GdkAtom!/g
|
||||
s/UnsafeMutablePointer<GdkAtom>/GdkAtom/
|
||||
s/targets: UnsafePointer<GdkAtom>/targets: UnsafePointer<GdkAtom?>/
|
||||
s/GdkAtom!.self/_GdkAtom.self/
|
||||
s/actual_property_type: AtomT/actual_property_type: UnsafeMutablePointer<GdkAtom?>/
|
||||
s/property: GdkAtom!, type: GdkAtom!/property: AtomT!, type: AtomT!/
|
||||
s/property, type/property._ptr, type._ptr/
|
||||
s/propertyGet<WindowT: WindowProtocol>/propertyGet<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/propertyChange<WindowT: WindowProtocol>/propertyChange<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/func propertyChange(property: AtomT/func propertyChange<AtomT: AtomProtocol>(property: AtomT/
|
||||
s/\(propertyGet.*\)window: WindowT, property: AtomT!, type: AtomT!/\1window: WindowT, property: UnsafeMutablePointer<GdkAtom?>, type: AtomT!/
|
||||
s/(gdk_property_get(window.window_ptr, property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), _ptr, actual_format, actual_length, data)/(gdk_property_get(window.window_ptr, _ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), property, actual_format, actual_length, data)/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol, WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propType: AtomT/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol>(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propType: AtomT, propFormat: UnsafeMutablePointer<gint>!) -> Int/selectionPropertyGet(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>, propertyFormat: UnsafeMutablePointer<gint>!) -> Int/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propFormat/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, property _ptr: UnsafeMutablePointer<GdkAtom?>, propertyFormat/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propertyType: UnsafeMutablePointer<GdkAtom.>!, propFormat:/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!, propertyFormat:/
|
||||
s/property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type._ptr/_ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type/
|
||||
s/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, propType._ptr, propFormat))/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, propertyType, propertyFormat))/
|
||||
s/Int(gdk_selection_property_get(window_ptr, data, propType._ptr, propFormat))/Int(gdk_selection_property_get(window_ptr, data, propertyType, propertyFormat))/
|
||||
s/Int(gdk_selection_property_get(requestor.window_ptr, data, _ptr, propFormat))/Int(gdk_selection_property_get(requestor.window_ptr, data, _ptr, propertyFormat))/
|
||||
s/gdk_gl_context_set_use_es(gl_context_ptr, gint(newValue))/gdk_gl_context_set_use_es(gl_context_ptr, newValue ? 1 : 0)/
|
||||
s/: \([A-Za-z.]*Notify[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Func[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Marshal[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Marshaller[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Callback[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Accumulator[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Handler[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transformer[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transform[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Transformer =\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Hook[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Mapping[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Listener[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*ListenerInit[,)]\)/: @escaping \1/g
|
||||
s/GObject.Callback/GLibObject.Callback/g
|
||||
s/func endPaint/@available(*, deprecated) func endPaint/
|
||||
s/public func beep/@available(*, deprecated) public func beep/
|
||||
s/public func errorTrap/@available(*, deprecated) public func errorTrap/
|
||||
s/public func flush/@available(*, deprecated) public func flush/
|
||||
s/public func setDoubleClickTime/@available(*, deprecated) public func setDoubleClickTime/
|
||||
s/_ptr.pointee.state = newValue.value/_ptr.pointee.state = newValue.rawValue/
|
||||
s/targets: GdkAtom/targets: UnsafePointer<GdkAtom?>/
|
||||
s/\(gdk_crossing_event.*\)crossing_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_button_event.*\)button_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_dnd_event.*\)dnd_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_focus_event.*\)focus_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_grab_broken_event.*\)grab_broken_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_key_event.*\)key_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_pad_event.*\)pad_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_scroll_event.*\)scroll_\(event_ptr\)/\1\2/
|
||||
s/\(gdk_touch.*_event.*\)touch.*_\(event_ptr\)/\1\2/
|
||||
s/\(init<DisplayT: DisplayProtocol>.\)toplevel \(display: DisplayT\)/\1\2/
|
||||
s/\(new<DisplayT: DisplayProtocol>.\)toplevel \(display: DisplayT\)/\1\2/
|
|
@ -1,4 +1,4 @@
|
|||
// swift-tools-version:5.6
|
||||
// swift-tools-version:5.3
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
@ -6,32 +6,20 @@ let package = Package(
|
|||
name: "Gdk",
|
||||
products: [ .library(name: "Gdk", targets: ["Gdk"]) ],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/rhx/gir2swift.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftGdkPixbuf.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftPangoCairo.git", branch: "main"),
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("swif52")),
|
||||
.package(name: "GdkPixbuf", url: "https://github.com/rhx/SwiftGdkPixbuf.git", .branch("swif52")),
|
||||
.package(name: "PangoCairo", url: "https://github.com/rhx/SwiftPangoCairo.git", .branch("swif52")),
|
||||
],
|
||||
targets: [
|
||||
.systemLibrary(name: "CGdk", pkgConfig: "gdk-3.0",
|
||||
.systemLibrary(name: "CGdk", pkgConfig: "gtk4",
|
||||
providers: [
|
||||
.brew(["gtk+3", "glib", "glib-networking", "gobject-introspection"]),
|
||||
.apt(["libgtk-3-dev", "libglib2.0-dev", "glib-networking", "gobject-introspection", "libgirepository1.0-dev"])
|
||||
.brew(["gtk4", "glib", "glib-networking", "gobject-introspection"]),
|
||||
.apt(["libgtk-4-dev", "libglib2.0-dev", "glib-networking", "gobject-introspection", "libgirepository1.0-dev"])
|
||||
]),
|
||||
.target(
|
||||
name: "Gdk",
|
||||
dependencies: [
|
||||
"CGdk",
|
||||
.product(name: "gir2swift", package: "gir2swift"),
|
||||
.product(name: "GdkPixBuf", package: "SwiftGdkPixbuf"),
|
||||
.product(name: "PangoCairo", package: "SwiftPangoCairo"),
|
||||
],
|
||||
swiftSettings: [
|
||||
.unsafeFlags(["-suppress-warnings"], .when(configuration: .release)),
|
||||
.unsafeFlags(["-suppress-warnings", "-Xfrontend", "-serialize-debugging-options"], .when(configuration: .debug)),
|
||||
],
|
||||
plugins: [
|
||||
.plugin(name: "gir2swift-plugin", package: "gir2swift")
|
||||
]
|
||||
dependencies: ["CGdk", "GdkPixbuf", "PangoCairo"],
|
||||
swiftSettings: [.unsafeFlags(["-Xfrontend", "-serialize-debugging-options"], .when(configuration: .debug))]
|
||||
),
|
||||
.testTarget(name: "GdkTests", dependencies: ["Gdk"]),
|
||||
]
|
||||
|
|
126
README.md
126
README.md
|
@ -11,78 +11,114 @@ For up to date (auto-generated) reference documentation, see https://rhx.github.
|
|||
|
||||
## What is new?
|
||||
|
||||
Support for gtk 4 was added via the `gtk4` branch.
|
||||
This branch supports Swift 5.2, but is now unmaintained.
|
||||
The `main` and `development` branches will require newer versions of Swift.
|
||||
|
||||
Support for gtk 4 for Swift 5.2 is available via the `gtk4-swift52` branch.
|
||||
|
||||
Version 12 of gir2swift pulls in [PR#10](https://github.com/rhx/gir2swift/pull/10), addressing several issues:
|
||||
|
||||
- Improvements to the Build experience and LSP [rhx/SwiftGtk#34](https://github.com/rhx/SwiftGtk/issues/34)
|
||||
- Fix issues with LLDB [rhx/SwiftGtk#39](https://github.com/rhx/SwiftGtk/issues/39)
|
||||
- **Controversial:** Implicitly marks all declarations named "priv" as if they had attribute `private=1`
|
||||
- Prevents all "Private" records from generating unless generated in their instance record
|
||||
- `-a` option generates all records
|
||||
- Introduces CI
|
||||
- For Class metadata types no longer generates class wrappers. Ref structs now contain static method which returnes the GType of the class and instance of the Class metatype wrapped in the Ref struct.
|
||||
- Adds final class GWeak<T> where T could be any Ref struct of a type which supports ARC. This class is a property wrapper which contains weak reference to any instance of T. This is especially beneficial for capture lists.
|
||||
- Adds support for weak observation.
|
||||
- Constructors and factories of GObjectInitiallyUnowned classes now consume floating reference upon initialisation as advised by [the GObject documentation](https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html)
|
||||
|
||||
Partially implemented:
|
||||
- Typed signal generation. Issues shown in [rhx/SwiftGtk#35](https://github.com/rhx/SwiftGtk/issues/35) hat remain to be addressed are listed here: [mikolasstuchlik/gir2swift#2](https://github.com/mikolasstuchlik/gir2swift/pull/2).
|
||||
|
||||
### Other Notable changes
|
||||
|
||||
Version 11 introduces a new type system into `gir2swift`,
|
||||
to ensure it has a representation of the underlying types.
|
||||
This is necessary for Swift 5.3 onwards, which requires more stringent casts.
|
||||
As a consequence, accessors can accept and return idiomatic Swift rather than
|
||||
underlying types or pointers.
|
||||
This means that a lot of the changes will be source-breaking for code that
|
||||
was compiled against libraries built with earlier versions of `gir2swift`.
|
||||
|
||||
* Requires Swift 5.2 or later (Swift 5.3 is required for the `gtk4` branch)
|
||||
* Uses the namespace referenced in the `gir` file
|
||||
* Wrapper code is now `@inlinable` to enable the compiler to optimise away most of the wrappers
|
||||
* Parameters and return types use more idiomatic Swift (e.g. `Ref` wrappers instead of pointers, `Int` instead of `gint`, etc.)
|
||||
* Functions that take or return records now are templated instead of using the type-erased Protocol
|
||||
* `ErrorType` has been renamed `GLibError` to ensure it neither clashes with `Swift.Error` nor the `GLib.ErrorType` scanner enum
|
||||
* Parameters or return types for records/classes now use the corresponding, lightweight Swift `Ref` wrapper instead of the underlying pointer
|
||||
|
||||
Version 15 of gir2swift provides a Package Manager Plugin. This requires Swift 5.6 or higher.
|
||||
(older versions can be used via the [swift52](https://github.com/rhx/SwiftGdk/tree/swift52) branch).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Swift 5.6 or higher
|
||||
### Swift
|
||||
|
||||
To build, download Swift from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well). Test that your compiler works using `swift --version`, which should give you something like
|
||||
To build, you need at least Swift 5.2 (Swift 5.3 is required for `gtk4`; also some Linux distributions have issues and seem to **require at least Swift 5.5**), download from https://swift.org/download/ -- if you are using macOS, make sure you have the command line tools installed as well). Test that your compiler works using `swift --version`, which should give you something like
|
||||
|
||||
$ swift --version
|
||||
swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
|
||||
Target: x86_64-apple-darwin20.3.0
|
||||
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
|
||||
Target: x86_64-apple-macosx12.0
|
||||
|
||||
on macOS, or on Linux you should get something like:
|
||||
|
||||
$ swift --version
|
||||
Swift version 5.6.1 (swift-5.6.1-RELEASE)
|
||||
Swift version 5.5.2 (swift-5.5.2-RELEASE)
|
||||
Target: x86_64-unknown-linux-gnu
|
||||
|
||||
### Gtk 3.22 or higher
|
||||
|
||||
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66, 2.68, 2.70 and 2.72, and gdk/gtk 3.22 and 3.24 as well as 4.0, 4.2, 4.4, and 4.6 on the gtk4 branch. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
|
||||
The Swift wrappers have been tested with glib-2.56, 2.58, 2.60, 2.62, 2.64, 2.66 and 2.68, and gdk/gtk 3.22, 3.24, 4.0, 4.2, 4.4, and 4.6. They should work with higher versions, but YMMV. Also make sure you have `gobject-introspection` and its `.gir` files installed.
|
||||
|
||||
#### Linux
|
||||
|
||||
##### Ubuntu
|
||||
|
||||
On Ubuntu 20.04 and 22.04 you can use the glib that comes with the distribution. Just install with the `apt` package manager:
|
||||
On Ubuntu 18.04 and 16.04 you can use the gtk that comes with the distribution. Just install with the `apt` package manager:
|
||||
|
||||
sudo apt update
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libcogl-dev gir1.2-cogl-1.0 libcogl-pango-dev gir1.2-coglpango-1.0 libgdk-pixbuf2.0-dev gir1.2-gdkpixbuf-2.0 libgirepository1.0-dev libxml2-dev
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libgirepository1.0-dev libxml2-dev
|
||||
|
||||
If you prefer a newer version of gtk, you can also install it from the GNOME 3 Staging PPA (see https://launchpad.net/~gnome3-team/+archive/ubuntu/gnome3-staging), but be aware that this can be a bit dangerous (as this removes packages that can be vital, particularly if you use a GNOME-based desktop), so only do this if you know what you are doing:
|
||||
|
||||
sudo add-apt-repository ppa:gnome3-team/gnome3-staging
|
||||
sudo apt update
|
||||
sudo apt dist-upgrade
|
||||
sudo apt install libgtk-3-dev gir1.2-gtk-3.0 gir1.2-gtksource-3.0 libgirepository1.0-dev libxml2-dev
|
||||
|
||||
##### Fedora
|
||||
|
||||
On Fedora, you can use the gtk that comes with the distribution. Just install with the `dnf` package manager:
|
||||
On Fedora 29, you can use the gtk that comes with the distribution. Just install with the `dnf` package manager:
|
||||
|
||||
sudo dnf install gtk3-devel pango-devel cogl-devel gdk-pixbuf2-devel cairo-devel cairo-gobject-devel glib2-devel gobject-introspection-devel libxml2-devel
|
||||
sudo dnf install gtk3-devel pango-devel cairo-devel cairo-gobject-devel glib2-devel gobject-introspection-devel libxml2-devel
|
||||
|
||||
#### macOS
|
||||
|
||||
On macOS, you can install gdk and gtk using HomeBrew (for setup instructions, see http://brew.sh). Once you have a running HomeBrew installation, you can use it to install a native version of gtk:
|
||||
|
||||
brew update
|
||||
brew install gtk+3 glib glib-networking gobject-introspection pkg-config
|
||||
brew install gtk4 glib glib-networking gobject-introspection pkg-config
|
||||
|
||||
## Usage
|
||||
|
||||
Normally, you don't build this package directly (but for testing you can - see 'Building' below). Instead you need to embed SwiftGdk into your own project using the [Swift Package Manager](https://swift.org/package-manager/). After installing the prerequisites (see 'Prerequisites' below), add `SwiftGdk` as a dependency to your `Package.swift` file, e.g.:
|
||||
|
||||
```Swift
|
||||
// swift-tools-version:5.6
|
||||
// swift-tools-version:5.3
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(name: "MyPackage",
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/rhx/gir2swift.git", branch: "main"),
|
||||
.package(url: "https://github.com/rhx/SwiftGdk.git", branch: "gtk3"),
|
||||
.package(name: "gir2swift", url: "https://github.com/rhx/gir2swift.git", .branch("main")),
|
||||
.package(name: "Gdk", url: "https://github.com/rhx/SwiftGdk.git", .branch("gtk4")),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "MyPackage",
|
||||
dependencies: [
|
||||
.product(name: "Gdk", package: "SwiftGdk")
|
||||
]
|
||||
)
|
||||
]
|
||||
targets: [.target(name: "MyPackage", dependencies: ["Gdk"])]
|
||||
)
|
||||
```
|
||||
|
||||
For gtk4 replace `.branch("gtk3")` with `.branch("gtk4")`.
|
||||
For gtk3 replace `.branch("gtk4")` with `.branch("gtk3")`.
|
||||
|
||||
## Building
|
||||
|
||||
|
@ -90,9 +126,17 @@ Normally, you don't build this package directly, but you embed it into your own
|
|||
|
||||
git clone https://github.com/rhx/SwiftGdk.git
|
||||
cd SwiftGdk
|
||||
./run-gir2swift.sh
|
||||
swift build
|
||||
swift test
|
||||
|
||||
Please note that on macOS, due to a bug currently in the Swift Package Manager,
|
||||
you need to pass in the build flags manually, i.e. instead of `swift build` and `swift test` you can run
|
||||
|
||||
swift build `./run-gir2swift.sh flags -noUpdate`
|
||||
swift test `./run-gir2swift.sh flags -noUpdate`
|
||||
|
||||
|
||||
### Xcode
|
||||
|
||||
On macOS, you can build the project using Xcode instead. To do this, you need to create an Xcode project first, then open the project in the Xcode IDE:
|
||||
|
@ -103,27 +147,21 @@ On macOS, you can build the project using Xcode instead. To do this, you need t
|
|||
|
||||
After that, use the (usual) Build and Test buttons to build/test this package.
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
You can generate documentation using the [DocC plugin](https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/). To preview documentation matching your local installation, simply run
|
||||
You can find reference documentation inside the [docs](https://rhx.github.io/SwiftGdk/) folder.
|
||||
This was generated using the [jazzy](https://github.com/realm/jazzy) tool.
|
||||
If you want to generate your own documentation, matching your local installation,
|
||||
you can use the `generate-documentation.sh` script in the repository.
|
||||
Unfortunately, at this stage [jazzy](https://github.com/realm/jazzy) only works on macOS (and crashes under Linux), so this will currently only work on a Mac.
|
||||
|
||||
swift package --disable-sandbox preview-documentation
|
||||
|
||||
then navigate to the URL shown for the local preview server. Make sure you have JavaScript enabled in your browser.
|
||||
|
||||
Alternatively, you can create static documentation using [jazzy](https://github.com/realm/jazzy).
|
||||
Make sure you have [sourcekitten](https://github.com/jpsim/SourceKitten) and [jazzy](https://github.com/realm/jazzy) installed, e.g. on macOS (x86_64):
|
||||
|
||||
brew install ruby sourcekitten
|
||||
/usr/local/opt/ruby/bin/gem install jazzy
|
||||
./generate-jazzy.sh
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Here are some common errors you might encounter and how to fix them.
|
||||
|
||||
### Missing `.gir` Files
|
||||
|
||||
If you get an error such as
|
||||
|
||||
Girs located at
|
||||
|
@ -132,15 +170,23 @@ If you get an error such as
|
|||
Make sure that you have the relevant `gobject-introspection` packages installed (as per the Pre-requisites section), including their `.gir` and `.pc` files.
|
||||
|
||||
### Old Swift toolchain or Xcode
|
||||
|
||||
If, when you run `swift build`, you get a `Segmentation fault (core dumped)` or circular dependency error such as
|
||||
|
||||
warning: circular dependency detected while parsing pangocairo: harfbuzz -> freetype2 -> harfbuzz
|
||||
|
||||
this probably means that your Swift toolchain is too old, particularly on Linux.
|
||||
Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).
|
||||
this probably means that your Swift toolchain is too old, particularly on Linux (at the time of this writing, some Linux distributions require at least Swift 5.5). Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).
|
||||
|
||||
If you get an older version, make sure that the right version of the swift compiler is found first in your `PATH`. On macOS, use xcode-select to select and install the latest version, e.g.:
|
||||
|
||||
sudo xcode-select -s /Applications/Xcode.app
|
||||
xcode-select --install
|
||||
|
||||
### Known Issues
|
||||
|
||||
* When building, a lot of warnings appear. This is largely an issue with automatic `RawRepresentable` conformance in the Swift Standard library. As a workaround, you can turn this off by passing the `-Xswiftc -suppress-warnings` parameter when building.
|
||||
|
||||
* The current build system does not support directory paths with spaces (e.g. the `My Drive` directory used by Google Drive File Stream).
|
||||
|
||||
* BUILD_DIR is not supported in the current build system.
|
||||
|
||||
As a workaround, you can use the old build scripts, e.g. `./build.sh` (instead of `run-gir2swift.sh` and `swift build`) to build a package.
|
||||
|
|
|
@ -1,23 +1,41 @@
|
|||
struct _GdkAppLaunchContext {};
|
||||
struct _GdkAtom {};
|
||||
struct _GdkAxisUse {};
|
||||
struct _GdkButtonEvent {};
|
||||
struct _GdkByteOrder {};
|
||||
struct _GdkCairoContext {};
|
||||
struct _GdkClipboard {};
|
||||
struct _GdkContentDeserializer {};
|
||||
struct _GdkContentFormats {};
|
||||
struct _GdkContentFormatsBuilder {};
|
||||
struct _GdkContentSerializer {};
|
||||
struct _GdkCrossingEvent {};
|
||||
struct _GdkCrossingMode {};
|
||||
struct _GdkCursor {};
|
||||
struct _GdkCursorType {};
|
||||
struct _GdkDNDEvent {};
|
||||
struct _GdkDeleteEvent {};
|
||||
struct _GdkDevice {};
|
||||
struct _GdkDeviceManager {};
|
||||
struct _GdkDeviceType {};
|
||||
struct _GdkDisplay {};
|
||||
struct _GdkDisplayManager {};
|
||||
struct _GdkDrag {};
|
||||
struct _GdkDragAction {};
|
||||
struct _GdkDragContext {};
|
||||
struct _GdkDragProtocol {};
|
||||
struct _GdkDragSurface {};
|
||||
struct _GdkDragSurfaceInterface {};
|
||||
struct _GdkDrawContext {};
|
||||
struct _GdkDrop {};
|
||||
struct _GdkEvent {};
|
||||
struct _GdkEventFunc {};
|
||||
struct _GdkEventMask {};
|
||||
struct _GdkEventSequence {};
|
||||
struct _GdkFileList {};
|
||||
struct _GdkFilterFunc {};
|
||||
struct _GdkFilterReturn {};
|
||||
struct _GdkFocusEvent {};
|
||||
struct _GdkFrameClock {};
|
||||
struct _GdkFrameClockClass {};
|
||||
struct _GdkFrameClockPhase {};
|
||||
|
@ -26,28 +44,55 @@ struct _GdkFrameTimings {};
|
|||
struct _GdkFullscreenMode {};
|
||||
struct _GdkGLContext {};
|
||||
struct _GdkGLError {};
|
||||
struct _GdkGLTexture {};
|
||||
struct _GdkGLTextureClass {};
|
||||
struct _GdkGrabBrokenEvent {};
|
||||
struct _GdkGrabOwnership {};
|
||||
struct _GdkGrabStatus {};
|
||||
struct _GdkGravity {};
|
||||
struct _GdkInputMode {};
|
||||
struct _GdkInputSource {};
|
||||
struct _GdkKeyEvent {};
|
||||
struct _GdkKeymap {};
|
||||
struct _GdkMemoryTexture {};
|
||||
struct _GdkMemoryTextureClass {};
|
||||
struct _GdkModifierIntent {};
|
||||
struct _GdkModifierType {};
|
||||
struct _GdkMotionEvent {};
|
||||
struct _GdkNotifyType {};
|
||||
struct _GdkOwnerChange {};
|
||||
struct _GdkPadEvent {};
|
||||
struct _GdkPaintable {};
|
||||
struct _GdkPixbuf {};
|
||||
struct _GdkPopup {};
|
||||
struct _GdkPopupInterface {};
|
||||
struct _GdkPopupLayout {};
|
||||
struct _GdkPropMode {};
|
||||
struct _GdkPropertyState {};
|
||||
struct _GdkProximityEvent {};
|
||||
struct _GdkRectangle {};
|
||||
struct _GdkScreen {};
|
||||
struct _GdkScrollDirection {};
|
||||
struct _GdkScrollEvent {};
|
||||
struct _GdkSettingAction {};
|
||||
struct _GdkSnapshot {};
|
||||
struct _GdkSnapshotClass {};
|
||||
struct _GdkStatus {};
|
||||
struct _GdkSurface {};
|
||||
struct _GdkSurfaceClass {};
|
||||
struct _GdkTexture {};
|
||||
struct _GdkTextureClass {};
|
||||
struct _GdkToplevel {};
|
||||
struct _GdkToplevelInterface {};
|
||||
struct _GdkToplevelLayout {};
|
||||
struct _GdkToplevelSize {};
|
||||
struct _GdkTouchEvent {};
|
||||
struct _GdkTouchpadEvent {};
|
||||
struct _GdkTouchpadGesturePhase {};
|
||||
struct _GdkVisibilityState {};
|
||||
struct _GdkVisual {};
|
||||
struct _GdkVisualType {};
|
||||
struct _GdkVulkanContext {};
|
||||
struct _GdkWMDecoration {};
|
||||
struct _GdkWMFunction {};
|
||||
struct _GdkWindow {};
|
||||
|
@ -82,4 +127,9 @@ struct _GdkMonitorInterface {};
|
|||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <gdk/gdk.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
#undef GDK_ACTION_ALL
|
||||
#define GDK_ACTION_ALL 7
|
||||
|
||||
#undef GDK_MODIFIER_MASK
|
||||
#define GDK_MODIFIER_MASK 0x1C001F0F
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module CGdk [system] {
|
||||
header "gdk_bridging.h"
|
||||
|
||||
link "gdk-3"
|
||||
link "gtk-4"
|
||||
link "pangocairo-1.0"
|
||||
link "pangoft2-1.0"
|
||||
link "fontconfig"
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
//
|
||||
// Gdk.swift
|
||||
// SwiftGdk
|
||||
//
|
||||
// Created by Rene Hexel on 3/6/16.
|
||||
// Copyright © 2016, 2018, 2021 Rene Hexel. All rights reserved.
|
||||
//
|
||||
import CGdk
|
||||
import GLib
|
||||
|
||||
/// A callback function or closure that runs on a different thread
|
||||
public typealias ThreadCallback = () -> Bool
|
||||
|
||||
/// A closure holder for a thread callback
|
||||
@usableFromInline typealias ThreadCallbackHolder = ClosureHolder<Void, Bool>
|
||||
|
||||
/// Adds a closure holder containing a closure or function
|
||||
/// to be called whenever there are no higher priority events pending.
|
||||
/// If the function returns false it is automatically removed
|
||||
/// from the list of event sources and will not be called again.
|
||||
/// - Parameters:
|
||||
/// - p: The priority to run, such as `PRIORITY_HIGH_IDLE`
|
||||
/// - data: the callback holder
|
||||
/// - handler: The handler wrapping the closure holder
|
||||
/// - Returns: The ID (greater than 0) of the event source.
|
||||
@usableFromInline func _threadsAddIdle(priority p: Int32 = PRIORITY_DEFAULT_IDLE, data: ThreadCallbackHolder, handler: @convention(c) @escaping (gpointer) -> gboolean) -> Int {
|
||||
let opaqueHolder = Unmanaged.passRetained(data).toOpaque()
|
||||
let callback = unsafeBitCast(handler, to: GSourceFunc.self)
|
||||
let rv = threadsAddIdleFull(priority: Int(p), function: callback, data: opaqueHolder, notify: {
|
||||
if let swift = $0 {
|
||||
let holder = Unmanaged<ThreadCallbackHolder>.fromOpaque(swift)
|
||||
holder.release()
|
||||
}
|
||||
})
|
||||
return rv
|
||||
}
|
||||
|
||||
/// Adds a closure or function to be called whenever there
|
||||
/// are no higher priority events pending.
|
||||
/// If the function returns false it is automatically removed
|
||||
/// from the list of event sources and will not be called again.
|
||||
/// - Parameters:
|
||||
/// - p: The priority to run, such as `PRIORITY_HIGH_IDLE`
|
||||
/// - callback: The callback function or closure to call
|
||||
/// - Returns: The ID (greater than 0) of the event source.
|
||||
@inlinable public func threadsAddIdle(priority p: Int32 = PRIORITY_DEFAULT_IDLE, callback: @escaping ThreadCallback) -> Int {
|
||||
let rv = _threadsAddIdle(data: ThreadCallbackHolder(callback)) {
|
||||
let holder = Unmanaged<ThreadCallbackHolder>.fromOpaque($0).takeUnretainedValue()
|
||||
let rv: gboolean = holder.call(()) ? 1 : 0
|
||||
return rv
|
||||
}
|
||||
return rv
|
||||
}
|
|
@ -1,31 +1,18 @@
|
|||
import XCTest
|
||||
import GLib
|
||||
@testable import Gdk
|
||||
|
||||
class GdkTests: XCTestCase {
|
||||
|
||||
func testEvent() {
|
||||
let event = Event(type: .keyPress)
|
||||
XCTAssertEqual(event.type, event.event_ptr.pointee.type)
|
||||
XCTAssertEqual(event.type, EventType.keyPress)
|
||||
// FIXME: implement gdk-4 tests
|
||||
func testEmpty() {
|
||||
}
|
||||
|
||||
func testEventType() {
|
||||
let doubleButton = EventType.doubleButtonPress
|
||||
XCTAssertEqual(doubleButton, EventType._2buttonPress)
|
||||
}
|
||||
}
|
||||
|
||||
func testThreadsAddIdle() {
|
||||
let mainLoop = MainLoopRef(context: mainContextDefault(), isRunning: false)
|
||||
var done = false
|
||||
let id = threadsAddIdle(priority: PRIORITY_HIGH_IDLE) {
|
||||
done = true
|
||||
mainLoop.quit()
|
||||
return false
|
||||
}
|
||||
XCTAssertEqual(done, false)
|
||||
XCTAssertNotEqual(id, 0)
|
||||
mainLoop.run()
|
||||
XCTAssertEqual(done, true)
|
||||
extension GdkTests {
|
||||
static var allTests : [(String, (GdkTests) -> () throws -> Void)] {
|
||||
return [
|
||||
("testEmpty", testEmpty),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import XCTest
|
||||
@testable import GdkTests
|
||||
|
||||
XCTMain([
|
||||
testCase(GdkTests.allTests),
|
||||
])
|
1
build.sh
1
build.sh
|
@ -4,4 +4,5 @@
|
|||
# to determine compiler and linker flags
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
exec swift build --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
# Configuration for the module to compile, the Swift toolchain, and
|
||||
# the compiler and linker flags to use.
|
||||
#
|
||||
VER=3.0
|
||||
major=4
|
||||
VER=$major.0
|
||||
GLIB_VER=2.0
|
||||
JAZZY_VER=3.24.33
|
||||
JAZZY_VER=$major.2.1
|
||||
Mod=Gdk
|
||||
Module=${Mod}-$VER
|
||||
module=`echo "${Module}" | tr '[:upper:]' '[:lower:]'`
|
||||
|
@ -19,8 +20,8 @@ if [ -z "$BUILD_DIR" ]; then
|
|||
fi
|
||||
export PATH="${GIR2SWIFT_PATH}:${BUILD_DIR}/checkouts/gir2swift/.build/release:${BUILD_DIR}/checkouts/gir2swift/.build/debug:${PATH}:$PWD/.build/checkouts/gir2swift/.build/release:$PWD/.build/checkouts/gir2swift/.build/debug:${PATH}:/usr/local/opt/ruby/bin:`echo /usr/local/lib/ruby/gems/*/bin | tr ' ' '\n' | tail -n1`:${PATH}:`echo /var/lib/gems/*/gems/jazzy-*/bin/ | tr ' ' '\n' | tail -n1`:/usr/local/bin"
|
||||
export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:${PKG_CONFIG_PATH}
|
||||
LINKFLAGS=`pkg-config --libs $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
|
||||
CCFLAGS=`pkg-config --cflags $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed 's/^/-Xcc /' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
|
||||
LINKFLAGS=`pkg-config --libs gtk$major pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
|
||||
CCFLAGS=`pkg-config --cflags gtk$major pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed 's/^/-Xcc /' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/,/ -Xlinker /g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
|
||||
TAC="tail -r"
|
||||
if which tac >/dev/null 2>&1 ; then
|
||||
TAC=tac
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
#
|
||||
. ./config.sh
|
||||
./clean.sh
|
||||
exec rm -rf .swiftpm Package.pins Packages Package.resolved docs .docs.old Sources/${Mod}/*-*.swift Sources/${Mod}/${Module}.swift Sources/${Mod}/Swift${Mod}.swift ${Mod}.xcodeproj
|
||||
exec rm -rf Package.pins Packages Package.resolved Sources/${Mod}/*-*.swift Sources/${Mod}/${Module}.swift Sources/${Mod}/Swift${Mod}.swift ${Mod}.xcodeproj
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
# to determine compiler and linker flags
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
if [ -z "$@" ]; then
|
||||
JAZZY_ARGS="--theme fullwidth --author René Hexel --author_url https://experts.griffith.edu.au/9237-rene-hexel --github_url https://github.com/rhx/Swift$Mod --github-file-prefix https://github.com/rhx/Swift$Mod/tree/generated --root-url http://rhx.github.io/Swift$Mod/ --output docs"
|
||||
JAZZY_ARGS="--theme fullwidth --author René Hexel --author_url https://experts.griffith.edu.au/9237-rene-hexel --github_url https://github.com/rhx/Swift$Mod --github-file-prefix https://github.com/rhx/Swift$Mod/tree/gtk4-generated --root-url http://rhx.github.io/Swift$Mod/ --output docs"
|
||||
fi
|
||||
[ -e "$BUILD_DIR/build.db" ] || ./build.sh
|
||||
rm -rf .docs.old
|
||||
|
@ -15,3 +16,4 @@ sourcekitten doc --spm --module-name $Mod -- --build-path "$BUILD_DIR" \
|
|||
$CCFLAGS $LINKFLAGS > "$BUILD_DIR/$Mod-doc.json"
|
||||
jazzy --sourcekitten-sourcefile "$BUILD_DIR/$Mod-doc.json" --clean \
|
||||
--module-version $JAZZY_VER --module $Mod $JAZZY_ARGS "$@"
|
||||
rm -f .build 2>/dev/null
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Recursive swift code wrapper generator for gobject-introspection (.gir) files.
|
||||
# This calls the non-recursive gir-to-swift.sh to do the heavy lifting.
|
||||
#
|
||||
. ./config.sh
|
||||
./package.sh update
|
||||
if [ ! -x "${GIR2SWIFT_PATH}/gir2swift" -a \
|
||||
! -e "$BUILD_DIR/checkouts/gir2swift" ] ; then
|
||||
mkdir -p "$BUILD_DIR/checkouts" 2>/dev/null
|
||||
pushd "$BUILD_DIR/checkouts" >/dev/null
|
||||
git clone https://github.com/rhx/gir2swift.git
|
||||
popd >/dev/null 2>&1
|
||||
fi
|
||||
if [ ! -x "${GIR2SWIFT_PATH}/gir2swift" ] &&
|
||||
! -e "$BUILD_DIR/checkouts/gir2swift/.build/release/gir2swift" >/dev/null 2>&1 ; then
|
||||
pushd "$BUILD_DIR/checkouts/gir2swift" >/dev/null
|
||||
./build.sh
|
||||
fi
|
||||
export PATH="$PWD/.build/release:${PATH}"
|
||||
popd >/dev/null 2>&1
|
||||
export PACKAGES="${BUILD_DIR}/checkouts"
|
||||
[ -e $PACKAGES ] || export PACKAGES=Packages
|
||||
if which parallel >/dev/null ; then
|
||||
for gen in $PACKAGES/*/gir-to-swift.sh ; do \
|
||||
echo echo \"Generate Swift Wrapper for `basename $(dirname $gen) | cut -d- -f1`\" \; \
|
||||
"( cd `dirname $gen` && ./`basename $gen` $@ )" ; \
|
||||
done | $TAC | parallel
|
||||
else
|
||||
for gen in $PACKAGES/*/gir-to-swift.sh ; do
|
||||
echo "Generate Swift Wrapper for `basename $(dirname $gen) | cut -d- -f1`"
|
||||
( cd `dirname $gen` && ./`basename $gen` "$@" )
|
||||
done
|
||||
fi
|
||||
. ./gir-to-swift.sh "$@"
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Swift code wrapper generator for gobject-introspection (.gir) files.
|
||||
# This needs an installed `gir2swift' executable (github.com/rhx/gir2swift)
|
||||
#
|
||||
. ./config.sh
|
||||
mkdir -p Sources/${Mod}
|
||||
GOBJECT_LIBDIR=`pkg-config --libs-only-L gobject-introspection-1.0 2>/dev/null | tr ' ' '\n' | grep gobject-introspection | tail -n1 | cut -c3-`
|
||||
GOBJECT_DIR=`dirname "${GOBJECT_LIBDIR}"`
|
||||
for prefix in $PREFIX /opt/homebrew /usr/local /usr $GOBJECT_DIR ; do
|
||||
gir_dir=${prefix}/share/gir-1.0
|
||||
gir=${gir_dir}/${Module}.gir
|
||||
if [ -e "${gir}" ] ; then
|
||||
export GIR=${gir}
|
||||
export GIR_DIR=${gir_dir}
|
||||
fi
|
||||
done
|
||||
if [ ! -e "${GIR}" ] ; then
|
||||
echo "*** ${GIR} does not exist!"
|
||||
echo "Make sure libgirepository1.0-dev is installed"
|
||||
echo "and can be found in /usr /usr/local or by pkg-config!"
|
||||
exit 1
|
||||
fi
|
||||
gir2swift -o Sources/${Mod} -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}"
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
GIR_NAME="Gdk-4.0"
|
||||
|
||||
function generate_arg-path_arg-g2s-exec_arg-gir-pre_arg-gir-path {
|
||||
local PACKAGE_PATH=$1
|
||||
local G2S_EXEC=$2
|
||||
local GIR_PRE=$3
|
||||
local GIR_PATH=$4
|
||||
|
||||
local CALLER=$PWD
|
||||
|
||||
cd $PACKAGE_PATH
|
||||
|
||||
local NAME=$(package_name)
|
||||
local GIR_PRE_ARGS=`for FILE in ${GIR_PRE}; do echo -n "-p ${GIR_PATH}/${FILE}.gir "; done`
|
||||
|
||||
bash -c "${G2S_EXEC} -o Sources/${NAME} ${GIR_PRE_ARGS} ${GIR_PATH}/${GIR_NAME}.gir"
|
||||
|
||||
cd $CALLER
|
||||
}
|
||||
|
||||
case $1 in
|
||||
gir-name) echo $GIR_NAME;;
|
||||
generate) echo $(generate_arg-path_arg-g2s-exec_arg-gir-pre_arg-gir-path "$2" "$3" "$4" "$5");;
|
||||
esac
|
|
@ -1,5 +0,0 @@
|
|||
version: 1
|
||||
gir-name: Gdk-3.0
|
||||
pkg-config: gdk-3.0
|
||||
output-directory: Sources/Gdk
|
||||
alpha-names: true
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
## Swift package with fetched dependencies is required to run scipt in gir2swift package. Use option -noUpdate to prevent update.
|
||||
if ! [[ $@ == *'-noUpdate'* ]]
|
||||
then
|
||||
swift package update
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
## Returns flags needed for macOS compilation (experimental)
|
||||
flags) .build/checkouts/gir2swift/gir2swift-generation-driver.sh c-flags $PWD ;;
|
||||
## Removes all generaed files
|
||||
clean) .build/checkouts/gir2swift/gir2swift-generation-driver.sh remove-generated $PWD ;;
|
||||
## Defaults to generation
|
||||
*) .build/checkouts/gir2swift/gir2swift-generation-driver.sh generate $PWD ;;
|
||||
esac
|
1
test.sh
1
test.sh
|
@ -4,4 +4,5 @@
|
|||
# that the swift wrapper code exists
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
exec swift test --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# and pass them to subprojects, based on the configured -I flags.
|
||||
#
|
||||
. ./config.sh
|
||||
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
|
||||
./package.sh generate-xcodeproj "$@"
|
||||
[ ! -e ${Mod}.xcodeproj/Configs ] || \
|
||||
( cd ${Mod}.xcodeproj/Configs && \
|
||||
|
|
Loading…
Reference in New Issue