Skip to content

Commit 4ffc782

Browse files
committed
format_and_lint
1 parent 941131e commit 4ffc782

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

Sources/GtkBackend/GtkBackend.swift

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,35 @@ public final class GtkBackend: AppBackend {
7474
let backend = Unmanaged<GtkBackend>.fromOpaque(userData).takeUnretainedValue()
7575
let key = OpaquePointer(instance)
7676
guard let ctx = backend.sheetContexts[key] else { return 1 }
77-
77+
7878
if ctx.interactiveDismissDisabled { return 1 }
79-
79+
8080
if ctx.isProgrammaticDismiss {
8181
ctx.isProgrammaticDismiss = false
8282
return 1
8383
}
84-
84+
8585
backend.runInMainThread {
8686
ctx.onDismiss()
8787
}
8888
return 1
8989
}
90-
90+
9191
// C-convention thunk for key-pressed
92-
private let escapeKeyPressedThunk: @convention(c) (
93-
UnsafeMutableRawPointer?, guint, guint, GdkModifierType, gpointer?
94-
) -> gboolean = { controller, keyval, keycode, state, userData in
95-
// TRUE (1) = consume event
96-
if keyval == GDK_KEY_Escape {
97-
guard let userData else { return 1 }
98-
let box = Unmanaged<ValueBox<() -> Void>>.fromOpaque(userData).takeUnretainedValue()
99-
box.value()
100-
return 1
92+
private let escapeKeyPressedThunk:
93+
@convention(c) (
94+
UnsafeMutableRawPointer?, guint, guint, GdkModifierType, gpointer?
95+
) -> gboolean = { controller, keyval, keycode, state, userData in
96+
// TRUE (1) = consume event
97+
if keyval == GDK_KEY_Escape {
98+
guard let userData else { return 1 }
99+
let box = Unmanaged<ValueBox<() -> Void>>.fromOpaque(userData).takeUnretainedValue()
100+
box.value()
101+
return 1
102+
}
103+
return 0
101104
}
102-
return 0
103-
}
104-
105+
105106
// A separate initializer to satisfy ``AppBackend``'s requirements.
106107
public convenience init() {
107108
self.init(appIdentifier: nil)
@@ -1637,7 +1638,7 @@ public final class GtkBackend: AppBackend {
16371638

16381639
let ctx = getOrCreateSheetContext(for: sheet)
16391640
ctx.onDismiss = onDismiss
1640-
1641+
16411642
sheet.css.set(property: .cornerRadius(defaultSheetCornerRadius))
16421643

16431644
if connectedCloseHandlers.insert(key).inserted {
@@ -1650,19 +1651,21 @@ public final class GtkBackend: AppBackend {
16501651
nil,
16511652
GConnectFlags(0)
16521653
)
1653-
1654+
16541655
let escapeHandler = gtk_event_controller_key_new()
16551656
gtk_event_controller_set_propagation_phase(escapeHandler, GTK_PHASE_BUBBLE)
1656-
g_signal_connect_data (
1657+
g_signal_connect_data(
16571658
UnsafeMutableRawPointer(escapeHandler),
16581659
"key-pressed",
16591660
unsafeBitCast(escapeKeyPressedThunk, to: GCallback.self),
1660-
Unmanaged.passRetained(ValueBox(value: {
1661-
if ctx.interactiveDismissDisabled { return }
1662-
self.runInMainThread {
1663-
ctx.onDismiss()
1664-
}
1665-
})).toOpaque(),
1661+
Unmanaged.passRetained(
1662+
ValueBox(value: {
1663+
if ctx.interactiveDismissDisabled { return }
1664+
self.runInMainThread {
1665+
ctx.onDismiss()
1666+
}
1667+
})
1668+
).toOpaque(),
16661669
{ data, _ in
16671670
if let data {
16681671
Unmanaged<ValueBox<() -> Void>>.fromOpaque(data).release()
@@ -1697,15 +1700,15 @@ public final class GtkBackend: AppBackend {
16971700

16981701
public func setInteractiveDismissDisabled(for sheet: Gtk.Window, to disabled: Bool) {
16991702
let ctx = getOrCreateSheetContext(for: sheet)
1700-
1703+
17011704
ctx.interactiveDismissDisabled = disabled
17021705
}
1703-
1706+
17041707
public func setPresentationCornerRadius(of sheet: Gtk.Window, to radius: Double) {
17051708
let radius = Int(radius)
17061709
sheet.css.set(property: .cornerRadius(radius))
17071710
}
1708-
1711+
17091712
private func getOrCreateSheetContext(for sheet: Gtk.Window) -> SheetContext {
17101713
let key: OpaquePointer = OpaquePointer(sheet.widgetPointer)
17111714
if let ctx = sheetContexts[key] {

Sources/SwiftCrossUI/Views/Modifiers/PresentationModifiers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension View {
2727
public func presentationCornerRadius(_ radius: Double) -> some View {
2828
preference(key: \.presentationCornerRadius, value: radius)
2929
}
30-
30+
3131
/// Sets the visibility of a sheet's drag indicator.
3232
///
3333
/// This modifier only affects the sheet presentation itself when applied to the
@@ -42,7 +42,7 @@ extension View {
4242
) -> some View {
4343
preference(key: \.presentationDragIndicatorVisibility, value: visibility)
4444
}
45-
45+
4646
/// Sets the background of a sheet.
4747
///
4848
/// This modifier only affects the sheet presentation itself when applied to the
@@ -53,7 +53,7 @@ extension View {
5353
public func presentationBackground(_ color: Color) -> some View {
5454
preference(key: \.presentationBackground, value: color)
5555
}
56-
56+
5757
/// Sets wether the user should be able to dismiss the sheet themself.
5858
///
5959
/// This modifier only affects the sheet presentation itself when applied to the

0 commit comments

Comments
 (0)