portico/Sources/Portico/Generated/VolumeButton.swift

72 lines
3.1 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.VolumeButton
/// `GtkVolumeButton` is a `GtkScaleButton` subclass tailored for
/// volume control.
///
/// <picture>
/// <source srcset="volumebutton-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkVolumeButton" src="volumebutton.png">
/// </picture>
///
/// A Portico view that mounts a `Gtk.VolumeButton`.
@MainActor public struct VolumeButton: View {
private let make: (MountContext) -> Gtk.VolumeButton
private var configure: [(Gtk.VolumeButton, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.VolumeButton.init()
/// Creates a `GtkVolumeButton`.
///
/// The button has a range between 0.0 and 1.0, with a stepping of 0.02.
/// Volume values can be obtained and modified using the functions from
/// [class`Gtk`.ScaleButton].
///
/// 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 adjustment: The `GtkAdjustment` that is used as the model.
/// - Parameter hasFrame: If the scale button has a frame.
/// - Parameter value: The value of the scale.
/// - Parameter onPopdown: Invoked when the widget emits the `popdown` signal.
/// - Parameter onPopup: Invoked when the widget emits the `popup` signal.
/// - Parameter onValueChanged: Invoked when the widget emits the `value-changed` signal. The closure receives the signal's arguments in order.
public init(adjustment: Gtk.Adjustment? = nil, hasFrame: Bool? = nil, value: Double? = nil, onPopdown: (() -> Void)? = nil, onPopup: (() -> Void)? = nil, onValueChanged: ((Double) -> Void)? = nil) {
make = { _ in Gtk.VolumeButton() }
configure.append { w, ctx in
if let adjustment { w.setAdjustment(adjustment: adjustment) }
if let hasFrame { w.setHasFrame(hasFrame: hasFrame) }
if let value { w.setValue(value: value) }
if let onPopdown { ctx.registry.add(w.connectPopdown { _ in onPopdown() }) }
if let onPopup { ctx.registry.add(w.connectPopup { _ in onPopup() }) }
if let onValueChanged { ctx.registry.add(w.connectValueChanged { _, a0 in onValueChanged(a0) }) }
}
}
}
extension VolumeButton: WidgetView {
public typealias Target = Gtk.VolumeButton
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.VolumeButton, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension VolumeButton: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}