344 lines
17 KiB
Swift
344 lines
17 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.FontButton
|
|
/// The `GtkFontButton` allows to open a font chooser dialog to change
|
|
/// the font.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="font-button-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkFontButton" src="font-button.png">
|
|
/// </picture>
|
|
///
|
|
/// It is suitable widget for selecting a font in a preference dialog.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// ```
|
|
/// fontbutton
|
|
/// ╰── button.font
|
|
/// ╰── [content]
|
|
/// ```
|
|
///
|
|
/// `GtkFontButton` 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.FontButton`.
|
|
@MainActor public struct FontButton: View {
|
|
private let make: (MountContext) -> Gtk.FontButton
|
|
private var configure: [(Gtk.FontButton, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.FontButton.init()
|
|
/// Creates a new font picker widget.
|
|
///
|
|
/// 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 modal: Whether the font chooser dialog should be modal.
|
|
/// - Parameter title: The title of 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.
|
|
/// - Parameter onFontSet: Invoked when the widget emits the `font-set` signal.
|
|
public init(modal: Bool? = nil, title: String? = nil, useFont: Bool? = nil, useSize: Bool? = nil, onActivate: (() -> Void)? = nil, onFontSet: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.FontButton() }
|
|
configure.append { w, ctx in
|
|
if let modal { w.setModal(modal: modal) }
|
|
if let title { w.setTitle(title: title) }
|
|
if let useFont { w.setUseFont(useFont: useFont) }
|
|
if let useSize { w.setUseSize(useSize: useSize) }
|
|
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
|
if let onFontSet { ctx.registry.add(w.connectFontSet { _ in onFontSet() }) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.FontButton.init(fontname:)
|
|
/// Creates a new font picker widget showing the given font.
|
|
///
|
|
/// 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 fontname: The `fontname` value forwarded to `Gtk.FontButton`.
|
|
/// - Parameter modal: Whether the font chooser dialog should be modal.
|
|
/// - Parameter title: The title of 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.
|
|
/// - Parameter onFontSet: Invoked when the widget emits the `font-set` signal.
|
|
public init(fontname: String, modal: Bool? = nil, title: String? = nil, useFont: Bool? = nil, useSize: Bool? = nil, onActivate: (() -> Void)? = nil, onFontSet: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.FontButton(fontname: fontname) }
|
|
configure.append { w, ctx in
|
|
if let modal { w.setModal(modal: modal) }
|
|
if let title { w.setTitle(title: title) }
|
|
if let useFont { w.setUseFont(useFont: useFont) }
|
|
if let useSize { w.setUseSize(useSize: useSize) }
|
|
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
|
if let onFontSet { ctx.registry.add(w.connectFontSet { _ in onFontSet() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension FontButton: WidgetView {
|
|
public typealias Target = Gtk.FontButton
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.FontButton, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension FontButton: 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.FontButton
|
|
/// Modifiers for `Gtk.FontButton`, available on every Portico view whose
|
|
/// backing widget is `Gtk.FontButton` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.FontButton {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontButton.setModal(modal:)
|
|
/// Sets whether the dialog should be modal.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter modal: Whether the font chooser dialog should be modal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func modal(_ modal: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setModal(modal: modal)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontButton.setModal(modal:), GObject.Object.connectNotify(detail:_:), Gtk.FontButton.getModal()
|
|
/// Sets whether the dialog should be modal.
|
|
///
|
|
/// 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 modal(_ modal: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, modal, registry: ctx.registry, notifyDetail: "modal",
|
|
read: { [w] in w.getModal() },
|
|
write: { [w] v in w.setModal(modal: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontButton.setModal(modal:)
|
|
/// Sets whether the dialog should be modal.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontButton.setModal(modal:)`.
|
|
///
|
|
/// - Parameter modal: Whether the font chooser dialog should be modal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func modal(_ modal: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setModal(modal: modal()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontButton.setTitle(title:)
|
|
/// Sets the title for the font chooser dialog.
|
|
///
|
|
/// 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 title: The title of the font chooser dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func title<S: StringProtocol>(_ title: S) -> Self {
|
|
appending { w, _ in
|
|
w.setTitle(title: String(title))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.FontButton.setTitle(title:), GObject.Object.connectNotify(detail:_:), Gtk.FontButton.getTitle()
|
|
/// Sets the title for the font chooser dialog.
|
|
///
|
|
/// 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 title(_ title: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, title, registry: ctx.registry, notifyDetail: "title",
|
|
read: { [w] in w.getTitle() },
|
|
write: { [w] v in w.setTitle(title: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.FontButton.setTitle(title:)
|
|
/// Sets the title for the font chooser dialog.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontButton.setTitle(title:)`.
|
|
///
|
|
/// - Parameter title: The title of the font chooser dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func title(_ title: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTitle(title: title()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.FontButton.setTitle(title:)
|
|
/// Sets the title for the font chooser dialog.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.FontButton.setTitle(title:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter title: The title of the font chooser dialog.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func title(_ title: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(title, registry: ctx.registry) { [w] v in w.setTitle(title: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.FontButton.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.FontButton.setUseFont(useFont:), GObject.Object.connectNotify(detail:_:), Gtk.FontButton.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.FontButton.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.FontButton.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.FontButton.setUseSize(useSize:)
|
|
/// If `use_size` is `true`, the font name will be written using
|
|
/// the selected 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.FontButton.setUseSize(useSize:), GObject.Object.connectNotify(detail:_:), Gtk.FontButton.getUseSize()
|
|
/// If `use_size` is `true`, the font name will be written using
|
|
/// the selected 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.FontButton.setUseSize(useSize:)
|
|
/// If `use_size` is `true`, the font name will be written using
|
|
/// the selected size.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.FontButton.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.FontButton.connectActivate(_:)
|
|
/// Emitted to when the font button is activated.
|
|
///
|
|
/// The `::activate` signal on `GtkFontButton` is an action signal and
|
|
/// emitting it causes the button to present 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() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.FontButton.connectFontSet(_:)
|
|
/// Emitted when the user selects a font.
|
|
///
|
|
/// When handling this signal, use [method`Gtk`.FontChooser.get_font]
|
|
/// to find out which font was just selected.
|
|
///
|
|
/// Note that this signal is only emitted when the user changes the font.
|
|
/// If you need to react to programmatic font changes as well, use
|
|
/// the notify::font signal.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `font-set` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onFontSet(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectFontSet { _ in handler() })
|
|
}
|
|
}
|
|
|
|
}
|