815 lines
44 KiB
Swift
815 lines
44 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: Adw.SplitButton
|
|
/// A combined button and dropdown widget.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="split-button-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img src="split-button.png" alt="split-button">
|
|
/// </picture>
|
|
///
|
|
/// `AdwSplitButton` is typically used to present a set of actions in a menu,
|
|
/// but allow access to one of them with a single click.
|
|
///
|
|
/// The API is very similar to [class`Gtk`.Button] and [class`Gtk`.MenuButton], see
|
|
/// their documentation for details.
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// ```
|
|
/// splitbutton[.image-button][.text-button]
|
|
/// ├── button
|
|
/// │ ╰── <content>
|
|
/// ├── separator
|
|
/// ╰── menubutton
|
|
/// ╰── button.toggle
|
|
/// ╰── arrow
|
|
/// ```
|
|
///
|
|
/// `AdwSplitButton`'s CSS node is called `splitbutton`. It contains the css
|
|
/// nodes: `button`, `separator`, `menubutton`. See [class`Gtk`.MenuButton]
|
|
/// documentation for the `menubutton` contents.
|
|
///
|
|
/// The main CSS node will contain the `.image-button` or `.text-button` style
|
|
/// classes matching the button contents. The nested button nodes will never
|
|
/// contain them.
|
|
///
|
|
/// ## Style classes
|
|
///
|
|
/// `AdwSplitButton` can use some of the same style classes as [class`Gtk`.Button]:
|
|
///
|
|
/// - [`.suggested-action`](style-classes.html`suggested`-action)
|
|
/// - [`.destructive-action`](style-classes.html`destructive`-action)
|
|
/// - [`.flat`](style-classes.html`flat`)
|
|
/// - [`.raised`](style-classes.html`raised`)
|
|
///
|
|
/// Other style classes, like `.pill`, cannot be used.
|
|
///
|
|
/// ## Accessibility
|
|
///
|
|
/// `AdwSplitButton` uses the [enum`Gtk`.AccessibleRole.group] role.
|
|
///
|
|
/// A Portico view that mounts a `Adw.SplitButton`.
|
|
@MainActor public struct SplitButton: View {
|
|
private let make: (MountContext) -> Adw.SplitButton
|
|
private var configure: [(Adw.SplitButton, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Adw.SplitButton.init()
|
|
/// Creates a new `AdwSplitButton`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
|
|
/// An empty closure adds no children and leaves slots unset.
|
|
/// 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 canShrink: Whether the button can be smaller than the natural size of its contents.
|
|
/// - Parameter direction: The direction in which the popup will be popped up.
|
|
/// - Parameter dropdownTooltip: The tooltip of the dropdown button.
|
|
/// - Parameter iconName: The name of the icon used to automatically populate the button.
|
|
/// - Parameter label: The label for the button.
|
|
/// - Parameter menuModel: The `GMenuModel` from which the popup will be created.
|
|
/// - Parameter popover: The `GtkPopover` that will be popped up when the dropdown is clicked.
|
|
/// - Parameter useUnderline: Whether an underline in the text indicates a mnemonic.
|
|
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
|
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
|
|
/// - Parameter onClicked: Invoked when the widget emits the `clicked` signal.
|
|
public init(canShrink: Bool? = nil, direction: Adw.ArrowType? = nil, dropdownTooltip: String? = nil, iconName: String? = nil, label: String? = nil, menuModel: Adw.MenuModel? = nil, popover: Adw.Popover? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil, onClicked: (() -> Void)? = nil) {
|
|
make = { _ in Adw.SplitButton() }
|
|
configure.append { w, ctx in
|
|
if let canShrink { w.setCanShrink(canShrink: canShrink) }
|
|
if let direction { w.setDirection(direction: direction) }
|
|
if let dropdownTooltip { w.setDropdownTooltip(tooltip: dropdownTooltip) }
|
|
if let iconName { w.setIconName(iconName: iconName) }
|
|
if let label { w.setLabel(label: label) }
|
|
if let menuModel { w.setMenuModel(menuModel: menuModel) }
|
|
if let popover { w.setPopover(popover: popover) }
|
|
if let useUnderline { w.setUseUnderline(useUnderline: useUnderline) }
|
|
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
|
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
|
|
if let onClicked { ctx.registry.add(w.connectClicked { _ in onClicked() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension SplitButton: WidgetView {
|
|
public typealias Target = Adw.SplitButton
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Adw.SplitButton, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension SplitButton: 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: Adw.SplitButton
|
|
/// Modifiers for `Adw.SplitButton`, available on every Portico view whose
|
|
/// backing widget is `Adw.SplitButton` or one of its subclasses.
|
|
extension WidgetView where Target: Adw.SplitButton {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setCanShrink(canShrink:)
|
|
/// Sets whether the button can be smaller than the natural size of its contents.
|
|
///
|
|
/// If set to `TRUE`, the label will ellipsize.
|
|
///
|
|
/// See [method`Gtk`.Button.set_can_shrink] and
|
|
/// [method`Gtk`.MenuButton.set_can_shrink].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canShrink: Whether the button can be smaller than the natural size of its contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canShrink(_ canShrink: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCanShrink(canShrink: canShrink)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setCanShrink(canShrink:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getCanShrink()
|
|
/// Sets whether the button can be smaller than the natural size of its contents.
|
|
///
|
|
/// If set to `TRUE`, the label will ellipsize.
|
|
///
|
|
/// See [method`Gtk`.Button.set_can_shrink] and
|
|
/// [method`Gtk`.MenuButton.set_can_shrink].
|
|
///
|
|
/// 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 canShrink(_ canShrink: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, canShrink, registry: ctx.registry, notifyDetail: "can-shrink",
|
|
read: { [w] in w.getCanShrink() },
|
|
write: { [w] v in w.setCanShrink(canShrink: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setCanShrink(canShrink:)
|
|
/// Sets whether the button can be smaller than the natural size of its contents.
|
|
///
|
|
/// If set to `TRUE`, the label will ellipsize.
|
|
///
|
|
/// See [method`Gtk`.Button.set_can_shrink] and
|
|
/// [method`Gtk`.MenuButton.set_can_shrink].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setCanShrink(canShrink:)`.
|
|
///
|
|
/// - Parameter canShrink: Whether the button can be smaller than the natural size of its contents.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func canShrink(_ canShrink: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCanShrink(canShrink: canShrink()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setChild(child:)
|
|
/// Sets the child widget.
|
|
///
|
|
/// Setting the child widget will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:icon-name] to `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: Adw.Widget?) -> Self {
|
|
appending { w, _ in
|
|
w.setChild(child: child)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Adw.SplitButton.setChild(child:)
|
|
/// Sets the child widget.
|
|
///
|
|
/// Setting the child widget will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:icon-name] to `NULL`.
|
|
///
|
|
/// The closure is evaluated once when the modifier is applied. Its first view is mounted into the slot.
|
|
/// Additional views are ignored; an empty closure leaves the slot unset.
|
|
///
|
|
/// - Parameter child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(@ViewBuilder _ child: () -> [AnyView]) -> Self {
|
|
let childViews = child()
|
|
return appending { w, ctx in
|
|
guard let v = childViews.first else { return }
|
|
w.setChild(child: v.makeWidget(ctx))
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getChild()
|
|
/// Sets the child widget.
|
|
///
|
|
/// Setting the child widget will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:icon-name] to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.Widget?` 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.SplitButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getChild()
|
|
/// Sets the child widget.
|
|
///
|
|
/// Setting the child widget will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:icon-name] to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Adw.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Widget?>` to be able to clear the property.
|
|
/// When `Adw.Widget` 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 child<W: Gtk.Widget>(_ child: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, child, registry: ctx.registry, notifyDetail: "child",
|
|
read: { [w] in w.getChild() as? W },
|
|
write: { [w] v in w.setChild(child: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setChild(child:)
|
|
/// Sets the child widget.
|
|
///
|
|
/// Setting the child widget will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:icon-name] to `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setChild(child:)`.
|
|
///
|
|
/// - Parameter child: The child widget.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func child(_ child: @escaping () -> Adw.Widget?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setChild(child: child()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setDirection(direction:)
|
|
/// Sets the direction in which the popup will be popped up.
|
|
///
|
|
/// The dropdown arrow icon will point at the same direction.
|
|
///
|
|
/// If the does not fit in the available space in the given direction, GTK will
|
|
/// try its best to keep it inside the screen and fully visible.
|
|
///
|
|
/// [enum`Gtk`.ArrowType.none] behaves same as [enum`Gtk`.ArrowType.down].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter direction: The direction in which the popup will be popped up.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func direction(_ direction: Adw.ArrowType) -> Self {
|
|
appending { w, _ in
|
|
w.setDirection(direction: direction)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setDirection(direction:), GObject.Object.connectNotify(detail:_:)
|
|
/// Sets the direction in which the popup will be popped up.
|
|
///
|
|
/// The dropdown arrow icon will point at the same direction.
|
|
///
|
|
/// If the does not fit in the available space in the given direction, GTK will
|
|
/// try its best to keep it inside the screen and fully visible.
|
|
///
|
|
/// [enum`Gtk`.ArrowType.none] behaves same as [enum`Gtk`.ArrowType.down].
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.ArrowType` 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 direction(_ direction: Portico.Binding<Adw.ArrowType>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, direction, registry: ctx.registry, notifyDetail: "direction",
|
|
read: { [w] in w.direction },
|
|
write: { [w] v in w.setDirection(direction: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setDirection(direction:)
|
|
/// Sets the direction in which the popup will be popped up.
|
|
///
|
|
/// The dropdown arrow icon will point at the same direction.
|
|
///
|
|
/// If the does not fit in the available space in the given direction, GTK will
|
|
/// try its best to keep it inside the screen and fully visible.
|
|
///
|
|
/// [enum`Gtk`.ArrowType.none] behaves same as [enum`Gtk`.ArrowType.down].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setDirection(direction:)`.
|
|
///
|
|
/// - Parameter direction: The direction in which the popup will be popped up.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func direction(_ direction: @escaping () -> Adw.ArrowType) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDirection(direction: direction()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setDropdownTooltip(tooltip:)
|
|
/// Sets the tooltip of the dropdown button of `self`.
|
|
///
|
|
/// The tooltip can be marked up with the Pango text markup language.
|
|
///
|
|
/// 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 dropdownTooltip: The tooltip of the dropdown button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func dropdownTooltip<S: StringProtocol>(_ dropdownTooltip: S) -> Self {
|
|
appending { w, _ in
|
|
w.setDropdownTooltip(tooltip: String(dropdownTooltip))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setDropdownTooltip(tooltip:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getDropdownTooltip()
|
|
/// Sets the tooltip of the dropdown button of `self`.
|
|
///
|
|
/// The tooltip can be marked up with the Pango text markup language.
|
|
///
|
|
/// 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 dropdownTooltip(_ dropdownTooltip: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, dropdownTooltip, registry: ctx.registry, notifyDetail: "dropdown-tooltip",
|
|
read: { [w] in w.getDropdownTooltip() },
|
|
write: { [w] v in w.setDropdownTooltip(tooltip: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setDropdownTooltip(tooltip:)
|
|
/// Sets the tooltip of the dropdown button of `self`.
|
|
///
|
|
/// The tooltip can be marked up with the Pango text markup language.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setDropdownTooltip(tooltip:)`.
|
|
///
|
|
/// - Parameter dropdownTooltip: The tooltip of the dropdown button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func dropdownTooltip(_ dropdownTooltip: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setDropdownTooltip(tooltip: dropdownTooltip()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.SplitButton.setDropdownTooltip(tooltip:)
|
|
/// Sets the tooltip of the dropdown button of `self`.
|
|
///
|
|
/// The tooltip can be marked up with the Pango text markup language.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.SplitButton.setDropdownTooltip(tooltip:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter dropdownTooltip: The tooltip of the dropdown button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func dropdownTooltip(_ dropdownTooltip: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(dropdownTooltip, registry: ctx.registry) { [w] v in w.setDropdownTooltip(tooltip: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setIconName(iconName:)
|
|
/// Sets the name of the icon used to automatically populate the button.
|
|
///
|
|
/// Setting the icon name will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// 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 iconName: The name of the icon used to automatically populate the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func iconName<S: StringProtocol>(_ iconName: S) -> Self {
|
|
appending { w, _ in
|
|
w.setIconName(iconName: String(iconName))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setIconName(iconName:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getIconName()
|
|
/// Sets the name of the icon used to automatically populate the button.
|
|
///
|
|
/// Setting the icon name will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// 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 iconName(_ iconName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, iconName, registry: ctx.registry, notifyDetail: "icon-name",
|
|
read: { [w] in w.getIconName() },
|
|
write: { [w] v in w.setIconName(iconName: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setIconName(iconName:)
|
|
/// Sets the name of the icon used to automatically populate the button.
|
|
///
|
|
/// Setting the icon name will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setIconName(iconName:)`.
|
|
///
|
|
/// - Parameter iconName: The name of the icon used to automatically populate the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func iconName(_ iconName: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setIconName(iconName: iconName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.SplitButton.setIconName(iconName:)
|
|
/// Sets the name of the icon used to automatically populate the button.
|
|
///
|
|
/// Setting the icon name will set [property`SplitButton`:label] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.SplitButton.setIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter iconName: The name of the icon used to automatically populate the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func iconName(_ iconName: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(iconName, registry: ctx.registry) { [w] v in w.setIconName(iconName: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setLabel(label:)
|
|
/// Sets the label for `self`.
|
|
///
|
|
/// Setting the label will set [property`SplitButton`:icon-name] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// 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 label: The label for the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func label<S: StringProtocol>(_ label: S) -> Self {
|
|
appending { w, _ in
|
|
w.setLabel(label: String(label))
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setLabel(label:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getLabel()
|
|
/// Sets the label for `self`.
|
|
///
|
|
/// Setting the label will set [property`SplitButton`:icon-name] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// 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 label(_ label: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, label, registry: ctx.registry, notifyDetail: "label",
|
|
read: { [w] in w.getLabel() },
|
|
write: { [w] v in w.setLabel(label: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setLabel(label:)
|
|
/// Sets the label for `self`.
|
|
///
|
|
/// Setting the label will set [property`SplitButton`:icon-name] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setLabel(label:)`.
|
|
///
|
|
/// - Parameter label: The label for the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func label(_ label: @escaping () -> String) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setLabel(label: label()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Adw.SplitButton.setLabel(label:)
|
|
/// Sets the label for `self`.
|
|
///
|
|
/// Setting the label will set [property`SplitButton`:icon-name] and
|
|
/// [property`SplitButton`:child] to `NULL`.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Adw.SplitButton.setLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter label: The label for the button.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func label(_ label: Portico.InterpolatedText) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindInterpolation(label, registry: ctx.registry) { [w] v in w.setLabel(label: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setMenuModel(menuModel:)
|
|
/// Sets the menu model from which the popup will be created.
|
|
///
|
|
/// If the menu model is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// A [class`Gtk`.Popover] will be created from the menu model with
|
|
/// [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as
|
|
/// documented for this function.
|
|
///
|
|
/// If [property`SplitButton`:popover] is already set, it will be dissociated from
|
|
/// the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter menuModel: The `GMenuModel` from which the popup will be created.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func menuModel(_ menuModel: Adw.MenuModel?) -> Self {
|
|
appending { w, _ in
|
|
w.setMenuModel(menuModel: menuModel)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getMenuModel()
|
|
/// Sets the menu model from which the popup will be created.
|
|
///
|
|
/// If the menu model is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// A [class`Gtk`.Popover] will be created from the menu model with
|
|
/// [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as
|
|
/// documented for this function.
|
|
///
|
|
/// If [property`SplitButton`:popover] is already set, it will be dissociated from
|
|
/// the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.MenuModel?` 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 menuModel(_ menuModel: Portico.Binding<Adw.MenuModel?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, menuModel, registry: ctx.registry, notifyDetail: "menu-model",
|
|
read: { [w] in w.getMenuModel() },
|
|
write: { [w] v in w.setMenuModel(menuModel: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.SplitButton.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getMenuModel()
|
|
/// Sets the menu model from which the popup will be created.
|
|
///
|
|
/// If the menu model is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// A [class`Gtk`.Popover] will be created from the menu model with
|
|
/// [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as
|
|
/// documented for this function.
|
|
///
|
|
/// If [property`SplitButton`:popover] is already set, it will be dissociated from
|
|
/// the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Adw.MenuModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.MenuModel?>` to be able to clear the property.
|
|
/// When `Adw.MenuModel` 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 menuModel(_ menuModel: Portico.Binding<Adw.MenuModel>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, menuModel, registry: ctx.registry, notifyDetail: "menu-model",
|
|
read: { [w] in w.getMenuModel() },
|
|
write: { [w] v in w.setMenuModel(menuModel: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setMenuModel(menuModel:)
|
|
/// Sets the menu model from which the popup will be created.
|
|
///
|
|
/// If the menu model is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// A [class`Gtk`.Popover] will be created from the menu model with
|
|
/// [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as
|
|
/// documented for this function.
|
|
///
|
|
/// If [property`SplitButton`:popover] is already set, it will be dissociated from
|
|
/// the button, and the property is set to `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setMenuModel(menuModel:)`.
|
|
///
|
|
/// - Parameter menuModel: The `GMenuModel` from which the popup will be created.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func menuModel(_ menuModel: @escaping () -> Adw.MenuModel?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setMenuModel(menuModel: menuModel()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setPopover(popover:)
|
|
/// Sets the popover that will be popped up when the dropdown is clicked.
|
|
///
|
|
/// If the popover is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// If [property`SplitButton`:menu-model] is set, the menu model is dissociated
|
|
/// from the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter popover: The `GtkPopover` that will be popped up when the dropdown is clicked.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func popover(_ popover: Adw.Popover?) -> Self {
|
|
appending { w, _ in
|
|
w.setPopover(popover: popover)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setPopover(popover:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getPopover()
|
|
/// Sets the popover that will be popped up when the dropdown is clicked.
|
|
///
|
|
/// If the popover is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// If [property`SplitButton`:menu-model] is set, the menu model is dissociated
|
|
/// from the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Adw.Popover?` 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 popover(_ popover: Portico.Binding<Adw.Popover?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, popover, registry: ctx.registry, notifyDetail: "popover",
|
|
read: { [w] in w.getPopover() },
|
|
write: { [w] v in w.setPopover(popover: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.SplitButton.setPopover(popover:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getPopover()
|
|
/// Sets the popover that will be popped up when the dropdown is clicked.
|
|
///
|
|
/// If the popover is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// If [property`SplitButton`:menu-model] is set, the menu model is dissociated
|
|
/// from the button, and the property is set to `NULL`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Adw.Popover>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.Popover?>` to be able to clear the property.
|
|
/// When `Adw.Popover` 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 popover(_ popover: Portico.Binding<Adw.Popover>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, popover, registry: ctx.registry, notifyDetail: "popover",
|
|
read: { [w] in w.getPopover() },
|
|
write: { [w] v in w.setPopover(popover: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setPopover(popover:)
|
|
/// Sets the popover that will be popped up when the dropdown is clicked.
|
|
///
|
|
/// If the popover is `NULL`, the dropdown is disabled.
|
|
///
|
|
/// If [property`SplitButton`:menu-model] is set, the menu model is dissociated
|
|
/// from the button, and the property is set to `NULL`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setPopover(popover:)`.
|
|
///
|
|
/// - Parameter popover: The `GtkPopover` that will be popped up when the dropdown is clicked.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func popover(_ popover: @escaping () -> Adw.Popover?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setPopover(popover: popover()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.SplitButton.setUseUnderline(useUnderline:)
|
|
/// Sets whether an underline in the text indicates a mnemonic.
|
|
///
|
|
/// See [property`SplitButton`:label].
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter useUnderline: Whether an underline in the text indicates a mnemonic.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func useUnderline(_ useUnderline: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setUseUnderline(useUnderline: useUnderline)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.SplitButton.setUseUnderline(useUnderline:), GObject.Object.connectNotify(detail:_:), Adw.SplitButton.getUseUnderline()
|
|
/// Sets whether an underline in the text indicates a mnemonic.
|
|
///
|
|
/// See [property`SplitButton`:label].
|
|
///
|
|
/// 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 useUnderline(_ useUnderline: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, useUnderline, registry: ctx.registry, notifyDetail: "use-underline",
|
|
read: { [w] in w.getUseUnderline() },
|
|
write: { [w] v in w.setUseUnderline(useUnderline: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.SplitButton.setUseUnderline(useUnderline:)
|
|
/// Sets whether an underline in the text indicates a mnemonic.
|
|
///
|
|
/// See [property`SplitButton`:label].
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.SplitButton.setUseUnderline(useUnderline:)`.
|
|
///
|
|
/// - Parameter useUnderline: Whether an underline in the text indicates a mnemonic.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func useUnderline(_ useUnderline: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setUseUnderline(useUnderline: useUnderline()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.SplitButton.connectActivate(_:)
|
|
/// Emitted to animate press then release.
|
|
///
|
|
/// This is an action signal. Applications should never connect to this signal,
|
|
/// but use the [signal`SplitButton`::clicked] signal.
|
|
///
|
|
/// - 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: Adw.SplitButton.connectClicked(_:)
|
|
/// Emitted when the button has been activated (pressed and released).
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `clicked` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onClicked(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectClicked { _ in handler() })
|
|
}
|
|
}
|
|
|
|
}
|