portico/Sources/Portico/Generated/FontDialogButton.swift

453 lines
24 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.FontDialogButton
/// Opens a font chooser dialog to select a font.
///
/// <picture>
/// <source srcset="font-button-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkFontDialogButton" src="font-button.png">
/// </picture>
///
/// It is suitable widget for selecting a font in a preference dialog.
///
/// # CSS nodes
///
/// ```
/// fontbutton
/// button.font
/// [content]
/// ```
///
/// `GtkFontDialogButton` has a single CSS node with name fontbutton which
/// contains a button node with the .font style class.
///
/// A Portico view that mounts a `Gtk.FontDialogButton`.
@MainActor public struct FontDialogButton: View {
private let make: (MountContext) -> Gtk.FontDialogButton
private var configure: [(Gtk.FontDialogButton, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.FontDialogButton.init(dialog:)
/// Creates a new `GtkFontDialogButton` with the
/// given `GtkFontDialog`.
///
/// You can pass `NULL` to this function and set a `GtkFontDialog`
/// later. The button will be insensitive until that happens.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter dialog: The `GtkFontDialog` that contains parameters for the font chooser dialog.
/// - Parameter fontDesc: The selected font.
/// - Parameter fontFeatures: The selected font features.
/// - Parameter level: The level of detail for the font chooser dialog.
/// - Parameter useFont: Whether the buttons label will be drawn in the selected font.
/// - Parameter useSize: Whether the buttons label will use the selected font size.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(dialog: Gtk.FontDialog?, fontDesc: Gtk.FontDescription? = nil, fontFeatures: String? = nil, level: Gtk.FontLevel? = nil, useFont: Bool? = nil, useSize: Bool? = nil, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.FontDialogButton(dialog: dialog) }
configure.append { w, ctx in
if let fontDesc { w.setFontDesc(fontDesc: fontDesc) }
if let fontFeatures { w.setFontFeatures(fontFeatures: fontFeatures) }
if let level { w.setLevel(level: level) }
if let useFont { w.setUseFont(useFont: useFont) }
if let useSize { w.setUseSize(useSize: useSize) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension FontDialogButton: WidgetView {
public typealias Target = Gtk.FontDialogButton
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.FontDialogButton, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension FontDialogButton: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Gtk.FontDialogButton
/// Modifiers for `Gtk.FontDialogButton`, available on every Portico view whose
/// backing widget is `Gtk.FontDialogButton` or one of its subclasses.
extension WidgetView where Target: Gtk.FontDialogButton {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setDialog(dialog:)
/// Sets a `GtkFontDialog` object to use for
/// creating the font chooser dialog that is
/// presented when the user clicks the button.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter dialog: The `GtkFontDialog` that contains parameters for the font chooser dialog.
/// - Returns: A copy of this view with the modifier applied.
public func dialog(_ dialog: Gtk.FontDialog) -> Self {
appending { w, _ in
w.setDialog(dialog: dialog)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setDialog(dialog:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getDialog()
/// Sets a `GtkFontDialog` object to use for
/// creating the font chooser dialog that is
/// presented when the user clicks the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.FontDialog` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func dialog(_ dialog: Portico.Binding<Gtk.FontDialog>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, dialog, registry: ctx.registry, notifyDetail: "dialog",
read: { [w] in w.getDialog() },
write: { [w] v in w.setDialog(dialog: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Gtk.FontDialogButton.setDialog(dialog:)
/// Sets a `GtkFontDialog` object to use for
/// creating the font chooser dialog that is
/// presented when the user clicks the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding and ignores `nil` values. Binds one way only.
///
/// - Returns: A copy of this view with the modifier applied.
public func dialog(_ dialog: Portico.Binding<Gtk.FontDialog?>) -> Self {
appending { w, ctx in
if let v = dialog.untrackedValue { w.setDialog(dialog: v) }
ctx.registry.add(dialog.subscribe { [w] v in if let v { w.setDialog(dialog: v) } })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setDialog(dialog:)
/// Sets a `GtkFontDialog` object to use for
/// creating the font chooser dialog that is
/// presented when the user clicks the button.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setDialog(dialog:)`.
///
/// - Parameter dialog: The `GtkFontDialog` that contains parameters for the font chooser dialog.
/// - Returns: A copy of this view with the modifier applied.
public func dialog(_ dialog: @escaping () -> Gtk.FontDialog) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setDialog(dialog: dialog()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setFontDesc(fontDesc:)
/// Sets the font of the button.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter fontDesc: The selected font.
/// - Returns: A copy of this view with the modifier applied.
public func fontDesc(_ fontDesc: Gtk.FontDescription) -> Self {
appending { w, _ in
w.setFontDesc(fontDesc: fontDesc)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setFontDesc(fontDesc:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getFontDesc()
/// Sets the font of the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.FontDescription` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func fontDesc(_ fontDesc: Portico.Binding<Gtk.FontDescription>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, fontDesc, registry: ctx.registry, notifyDetail: "font-desc",
read: { [w] in w.getFontDesc() },
write: { [w] v in w.setFontDesc(fontDesc: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Gtk.FontDialogButton.setFontDesc(fontDesc:)
/// Sets the font of the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding and ignores `nil` values. Binds one way only.
///
/// - Returns: A copy of this view with the modifier applied.
public func fontDesc(_ fontDesc: Portico.Binding<Gtk.FontDescription?>) -> Self {
appending { w, ctx in
if let v = fontDesc.untrackedValue { w.setFontDesc(fontDesc: v) }
ctx.registry.add(fontDesc.subscribe { [w] v in if let v { w.setFontDesc(fontDesc: v) } })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setFontDesc(fontDesc:)
/// Sets the font of the button.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setFontDesc(fontDesc:)`.
///
/// - Parameter fontDesc: The selected font.
/// - Returns: A copy of this view with the modifier applied.
public func fontDesc(_ fontDesc: @escaping () -> Gtk.FontDescription) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFontDesc(fontDesc: fontDesc()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setFontFeatures(fontFeatures:)
/// Sets the font features of the button.
///
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
///
/// - Parameter fontFeatures: The selected font features.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func fontFeatures<S: StringProtocol>(_ fontFeatures: S?) -> Self {
appending { w, _ in
w.setFontFeatures(fontFeatures: fontFeatures.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setFontFeatures(fontFeatures:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getFontFeatures()
/// Sets the font features of the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `String?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func fontFeatures(_ fontFeatures: Portico.Binding<String?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, fontFeatures, registry: ctx.registry, notifyDetail: "font-features",
read: { [w] in w.getFontFeatures() },
write: { [w] v in w.setFontFeatures(fontFeatures: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.FontDialogButton.setFontFeatures(fontFeatures:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getFontFeatures()
/// Sets the font features of the button.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func fontFeatures(_ fontFeatures: Portico.Binding<String>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, fontFeatures, registry: ctx.registry, notifyDetail: "font-features",
read: { [w] in w.getFontFeatures() },
write: { [w] v in w.setFontFeatures(fontFeatures: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setFontFeatures(fontFeatures:)
/// Sets the font features of the button.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setFontFeatures(fontFeatures:)`.
///
/// - Parameter fontFeatures: The selected font features.
/// - Returns: A copy of this view with the modifier applied.
public func fontFeatures(_ fontFeatures: @escaping () -> String?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFontFeatures(fontFeatures: fontFeatures()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.FontDialogButton.setFontFeatures(fontFeatures:)
/// Sets the font features of the button.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.FontDialogButton.setFontFeatures(fontFeatures:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter fontFeatures: The selected font features.
/// - Returns: A copy of this view with the modifier applied.
public func fontFeatures(_ fontFeatures: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(fontFeatures, registry: ctx.registry) { [w] v in w.setFontFeatures(fontFeatures: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setLevel(level:)
/// Sets the level of detail at which this dialog
/// lets the user select fonts.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter level: The level of detail for the font chooser dialog.
/// - Returns: A copy of this view with the modifier applied.
public func level(_ level: Gtk.FontLevel) -> Self {
appending { w, _ in
w.setLevel(level: level)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setLevel(level:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getLevel()
/// Sets the level of detail at which this dialog
/// lets the user select fonts.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.FontLevel` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func level(_ level: Portico.Binding<Gtk.FontLevel>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, level, registry: ctx.registry, notifyDetail: "level",
read: { [w] in w.getLevel() },
write: { [w] v in w.setLevel(level: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setLevel(level:)
/// Sets the level of detail at which this dialog
/// lets the user select fonts.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setLevel(level:)`.
///
/// - Parameter level: The level of detail for the font chooser dialog.
/// - Returns: A copy of this view with the modifier applied.
public func level(_ level: @escaping () -> Gtk.FontLevel) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setLevel(level: level()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setUseFont(useFont:)
/// If `use_font` is `TRUE`, the font name will be written
/// using the selected font.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useFont: Whether the buttons label will be drawn in the selected font.
/// - Returns: A copy of this view with the modifier applied.
public func useFont(_ useFont: Bool) -> Self {
appending { w, _ in
w.setUseFont(useFont: useFont)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setUseFont(useFont:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getUseFont()
/// If `use_font` is `TRUE`, the font name will be written
/// using the selected font.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func useFont(_ useFont: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useFont, registry: ctx.registry, notifyDetail: "use-font",
read: { [w] in w.getUseFont() },
write: { [w] v in w.setUseFont(useFont: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setUseFont(useFont:)
/// If `use_font` is `TRUE`, the font name will be written
/// using the selected font.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setUseFont(useFont:)`.
///
/// - Parameter useFont: Whether the buttons label will be drawn in the selected font.
/// - Returns: A copy of this view with the modifier applied.
public func useFont(_ useFont: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseFont(useFont: useFont()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontDialogButton.setUseSize(useSize:)
/// If `use_size` is `TRUE`, the font name will be written
/// using the selected font size.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useSize: Whether the buttons label will use the selected font size.
/// - Returns: A copy of this view with the modifier applied.
public func useSize(_ useSize: Bool) -> Self {
appending { w, _ in
w.setUseSize(useSize: useSize)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontDialogButton.setUseSize(useSize:), GObject.Object.connectNotify(detail:_:), Gtk.FontDialogButton.getUseSize()
/// If `use_size` is `TRUE`, the font name will be written
/// using the selected font size.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func useSize(_ useSize: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useSize, registry: ctx.registry, notifyDetail: "use-size",
read: { [w] in w.getUseSize() },
write: { [w] v in w.setUseSize(useSize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontDialogButton.setUseSize(useSize:)
/// If `use_size` is `TRUE`, the font name will be written
/// using the selected font size.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontDialogButton.setUseSize(useSize:)`.
///
/// - Parameter useSize: Whether the buttons label will use the selected font size.
/// - Returns: A copy of this view with the modifier applied.
public func useSize(_ useSize: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseSize(useSize: useSize()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FontDialogButton.connectActivate(_:)
/// Emitted when the font dialog button is activated.
///
/// The `::activate` signal on `GtkFontDialogButton` is an action signal
/// and emitting it causes the button to pop up its dialog.
///
/// - Parameter handler: Invoked when the widget emits the `activate` signal.
/// - Returns: A copy of this view with the modifier applied.
public func onActivate(_ handler: @escaping () -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectActivate { _ in handler() })
}
}
}