david-swift 8eeda083e9
All checks were successful
Deploy Docs / publish (push) Successful in 18m28s
SwiftLint / SwiftLint (push) Successful in 5s
Separate AnyView extensions from widgets
2024-10-16 14:22:34 +02:00

31 lines
761 B
Swift

//
// Popover+.swift
// Adwaita
//
// Created by david-swift on 10.02.24.
//
import CAdw
extension Popover {
/// Initialize either a horizontal or vertical clamp.
/// - Parameter vertical: Whether it is a vertical clamp.
public init(visible: Binding<Bool>) {
self.init()
updateFunctions.append { storage, _, _ in
storage.connectSignal(name: "closed", id: "visible") {
if visible.wrappedValue {
visible.wrappedValue = false
}
}
if visible.wrappedValue {
gtk_popover_popup(storage.opaquePointer?.cast())
} else {
gtk_popover_popdown(storage.opaquePointer?.cast())
}
}
}
}