portico/Sources/Portico/Generated/Expander.swift

764 lines
45 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.Expander
/// Allows the user to reveal or conceal a child widget.
///
/// <picture>
/// <source srcset="expander-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkExpander" src="expander.png">
/// </picture>
///
/// This is similar to the triangles used in a `GtkTreeView`.
///
/// Normally you use an expander as you would use a frame; you create
/// the child widget and use [method`Gtk`.Expander.set_child] to add it
/// to the expander. When the expander is toggled, it will take care of
/// showing and hiding the child automatically.
///
/// # Special Usage
///
/// There are situations in which you may prefer to show and hide the
/// expanded widget yourself, such as when you want to actually create
/// the widget at expansion time. In this case, create a `GtkExpander`
/// but do not add a child to it. The expander widget has an
/// [property`Gtk`.Expander:expanded] property which can be used to
/// monitor its expansion state. You should watch this property with
/// a signal connection as follows:
///
/// ```c
/// static void
/// expander_callback (GObject *object,
/// GParamSpec *param_spec,
/// gpointer user_data)
/// {
/// GtkExpander *expander;
///
/// expander = GTK_EXPANDER (object);
///
/// if (gtk_expander_get_expanded (expander))
/// {
/// // Show or create widgets
/// }
/// else
/// {
/// // Hide or destroy widgets
/// }
/// }
///
/// static void
/// create_expander (void)
/// {
/// GtkWidget *expander = gtk_expander_new_with_mnemonic ("_More Options");
/// g_signal_connect (expander, "notify::expanded",
/// G_CALLBACK (expander_callback), NULL);
///
/// // ...
/// }
/// ```
///
/// # GtkExpander as GtkBuildable
///
/// An example of a UI definition fragment with GtkExpander:
///
/// ```xml
/// <object class="GtkExpander">
/// <property name="label-widget">
/// <object class="GtkLabel" id="expander-label"/>
/// </property>
/// <property name="child">
/// <object class="GtkEntry" id="expander-content"/>
/// </property>
/// </object>
/// ```
///
/// # CSS nodes
///
/// ```
/// expander-widget
/// box
/// title
/// expander
/// <label widget>
/// <child>
/// ```
///
/// `GtkExpander` has a main node `expander-widget`, and subnode `box` containing
/// the title and child widget. The box subnode `title` contains node `expander`,
/// i.e. the expand/collapse arrow; then the label widget if any. The arrow of an
/// expander that is showing its child gets the `:checked` pseudoclass set on it.
///
/// # Accessibility
///
/// `GtkExpander` uses the [enum`Gtk`.AccessibleRole.button] role.
///
/// A Portico view that mounts a `Gtk.Expander`.
@MainActor public struct Expander: View {
private let make: (MountContext) -> Gtk.Expander
private var configure: [(Gtk.Expander, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Expander.init(label:)
/// Creates a new expander using `label` as the text of the label.
///
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for values that change.
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
/// 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 label: The text of the expanders label.
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - 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 labelWidget: A `ViewBuilder` closure whose first view is mounted into the `labelWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
@_disfavoredOverload
public init<S: StringProtocol>(label: S?, expanded: Bool? = nil, resizeToplevel: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder labelWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.Expander(label: label.map { String($0) }) }
configure.append { w, ctx in
if let expanded { w.setExpanded(expanded: expanded) }
if let resizeToplevel { w.setResizeToplevel(resizeToplevel: resizeToplevel) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
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 v = Portico.mountSlotChild(labelWidget, ctx, onUpdate: { v in w.setLabelWidget(labelWidget: v) }) { w.setLabelWidget(labelWidget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.Expander.init(label:), Gtk.Expander.setLabel(label:)
/// Creates a new expander using `label` as the text of the label.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.Expander.setLabel(label:)` without rebuilding the view.
/// 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.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter label: The text of the expanders label.
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - 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 labelWidget: A `ViewBuilder` closure whose first view is mounted into the `labelWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(label: Portico.Binding<String?>, expanded: Portico.Binding<Bool>? = nil, resizeToplevel: Portico.Binding<Bool>? = nil, useMarkup: Portico.Binding<Bool>? = nil, useUnderline: Portico.Binding<Bool>? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder labelWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.Expander(label: label.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(label.subscribe { [w] v in w.setLabel(label: v) })
if let expanded {
Portico.bindProperty(w, expanded, registry: ctx.registry, notifyDetail: "expanded", read: { [w] in w.getExpanded() }, write: { [w] v in w.setExpanded(expanded: v) })
}
if let resizeToplevel {
Portico.bindProperty(w, resizeToplevel, registry: ctx.registry, notifyDetail: "resize-toplevel", read: { [w] in w.getResizeToplevel() }, write: { [w] v in w.setResizeToplevel(resizeToplevel: v) })
}
if let useMarkup {
Portico.bindProperty(w, useMarkup, registry: ctx.registry, notifyDetail: "use-markup", read: { [w] in w.getUseMarkup() }, write: { [w] v in w.setUseMarkup(useMarkup: v) })
}
if let useUnderline {
Portico.bindProperty(w, useUnderline, registry: ctx.registry, notifyDetail: "use-underline", read: { [w] in w.getUseUnderline() }, write: { [w] v in w.setUseUnderline(useUnderline: v) })
}
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
if let v = Portico.mountSlotChild(labelWidget, ctx, onUpdate: { v in w.setLabelWidget(labelWidget: v) }) { w.setLabelWidget(labelWidget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
// PorticoGen: generateInits(closure) | source: Gtk.Expander.init(label:), Gtk.Expander.setLabel(label:)
/// Creates a new expander using `label` as the text of the label.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setLabel(label:)`.
/// 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 label: The text of the expanders label.
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - 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 labelWidget: A `ViewBuilder` closure whose first view is mounted into the `labelWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(label: @escaping () -> String?, expanded: Bool? = nil, resizeToplevel: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder labelWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.Expander(label: label()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setLabel(label: label()) }
t0.run()
ctx.registry.add(t0)
if let expanded { w.setExpanded(expanded: expanded) }
if let resizeToplevel { w.setResizeToplevel(resizeToplevel: resizeToplevel) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
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 v = Portico.mountSlotChild(labelWidget, ctx, onUpdate: { v in w.setLabelWidget(labelWidget: v) }) { w.setLabelWidget(labelWidget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
// PorticoGen: generateInits(interpolation) | source: Gtk.Expander.init(label:), Gtk.Expander.setLabel(label:)
/// Creates a new expander using `label` as the text of the label.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Expander.setLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
/// 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 label: The text of the expanders label.
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - 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 labelWidget: A `ViewBuilder` closure whose first view is mounted into the `labelWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(label: Portico.InterpolatedText?, expanded: Bool? = nil, resizeToplevel: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder labelWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.Expander(label: label?.untrackedText) }
configure.append { w, ctx in
Portico.bindOptionalInterpolation(label, registry: ctx.registry) { [w] v in w.setLabel(label: v) }
if let expanded { w.setExpanded(expanded: expanded) }
if let resizeToplevel { w.setResizeToplevel(resizeToplevel: resizeToplevel) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
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 v = Portico.mountSlotChild(labelWidget, ctx, onUpdate: { v in w.setLabelWidget(labelWidget: v) }) { w.setLabelWidget(labelWidget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Expander.init(withMnemonicLabel:)
/// Creates a new expander using `label` as the text of the label.
///
/// If characters in `label` are preceded by an underscore, they are
/// underlined. If you need a literal underscore character in a label,
/// use __ (two underscores). The first underlined character represents
/// a keyboard accelerator called a mnemonic.
///
/// Pressing Alt and that key activates the button.
///
/// 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 withMnemonicLabel: The `withMnemonicLabel` value forwarded to `Gtk.Expander`.
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - 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 labelWidget: A `ViewBuilder` closure whose first view is mounted into the `labelWidget` slot.
/// - Parameter onActivate: Invoked when the widget emits the `activate` signal.
public init(withMnemonicLabel: String?, expanded: Bool? = nil, resizeToplevel: Bool? = nil, useMarkup: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder labelWidget: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
make = { _ in Gtk.Expander(withMnemonicLabel: withMnemonicLabel) }
configure.append { w, ctx in
if let expanded { w.setExpanded(expanded: expanded) }
if let resizeToplevel { w.setResizeToplevel(resizeToplevel: resizeToplevel) }
if let useMarkup { w.setUseMarkup(useMarkup: useMarkup) }
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 v = Portico.mountSlotChild(labelWidget, ctx, onUpdate: { v in w.setLabelWidget(labelWidget: v) }) { w.setLabelWidget(labelWidget: v) }
if let onActivate { ctx.registry.add(w.connectActivate { _ in onActivate() }) }
}
}
}
extension Expander: WidgetView {
public typealias Target = Gtk.Expander
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Expander, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Expander: 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.Expander
/// Modifiers for `Gtk.Expander`, available on every Portico view whose
/// backing widget is `Gtk.Expander` or one of its subclasses.
extension WidgetView where Target: Gtk.Expander {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setChild(child:)
/// Sets the child widget of `expander`.
///
/// 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: Gtk.Widget?) -> Self {
appending { w, _ in
w.setChild(child: child)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Expander.setChild(child:)
/// Sets the child widget of `expander`.
///
/// 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: Gtk.Expander.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getChild()
/// Sets the child widget of `expander`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.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: Gtk.Expander.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getChild()
/// Sets the child widget of `expander`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
/// When `Gtk.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: Gtk.Expander.setChild(child:)
/// Sets the child widget of `expander`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setChild(child:)`.
///
/// - Parameter child: The child widget.
/// - Returns: A copy of this view with the modifier applied.
public func child(_ child: @escaping () -> Gtk.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: Gtk.Expander.setExpanded(expanded:)
/// Sets the state of the expander.
///
/// Set to `true`, if you want the child widget to be revealed,
/// and `false` if you want the child widget to be hidden.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Returns: A copy of this view with the modifier applied.
public func expanded(_ expanded: Bool) -> Self {
appending { w, _ in
w.setExpanded(expanded: expanded)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Expander.setExpanded(expanded:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getExpanded()
/// Sets the state of the expander.
///
/// Set to `true`, if you want the child widget to be revealed,
/// and `false` if you want the child widget to be hidden.
///
/// 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 expanded(_ expanded: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, expanded, registry: ctx.registry, notifyDetail: "expanded",
read: { [w] in w.getExpanded() },
write: { [w] v in w.setExpanded(expanded: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Expander.setExpanded(expanded:)
/// Sets the state of the expander.
///
/// Set to `true`, if you want the child widget to be revealed,
/// and `false` if you want the child widget to be hidden.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setExpanded(expanded:)`.
///
/// - Parameter expanded: Whether the expander has been opened to reveal the child.
/// - Returns: A copy of this view with the modifier applied.
public func expanded(_ expanded: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setExpanded(expanded: expanded()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setLabel(label:)
/// Sets the text of the label of the expander to `label`.
///
/// This will also clear any previously set labels.
///
/// 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 text of the expanders label.
/// - 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: label.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Expander.setLabel(label:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getLabel()
/// Sets the text of the label of the expander to `label`.
///
/// This will also clear any previously set labels.
///
/// 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 -> bindingModifier(lifted,twoWay) | source: Gtk.Expander.setLabel(label:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getLabel()
/// Sets the text of the label of the expander to `label`.
///
/// This will also clear any previously set labels.
///
/// 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 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: Gtk.Expander.setLabel(label:)
/// Sets the text of the label of the expander to `label`.
///
/// This will also clear any previously set labels.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setLabel(label:)`.
///
/// - Parameter label: The text of the expanders label.
/// - 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: Gtk.Expander.setLabel(label:)
/// Sets the text of the label of the expander to `label`.
///
/// This will also clear any previously set labels.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Expander.setLabel(label:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter label: The text of the expanders label.
/// - Returns: A copy of this view with the modifier applied.
public func label(_ label: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(label, registry: ctx.registry) { [w] v in w.setLabel(label: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setLabelWidget(labelWidget:)
/// Set the label widget for the expander.
///
/// This is the widget that will appear embedded alongside
/// the expander arrow.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter labelWidget: A widget to display instead of the usual expander label.
/// - Returns: A copy of this view with the modifier applied.
public func labelWidget(_ labelWidget: Gtk.Widget?) -> Self {
appending { w, _ in
w.setLabelWidget(labelWidget: labelWidget)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(viewBuilder) | source: Gtk.Expander.setLabelWidget(labelWidget:)
/// Set the label widget for the expander.
///
/// This is the widget that will appear embedded alongside
/// the expander arrow.
///
/// 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 labelWidget: A widget to display instead of the usual expander label.
/// - Returns: A copy of this view with the modifier applied.
public func labelWidget(@ViewBuilder _ labelWidget: () -> [AnyView]) -> Self {
let labelWidgetViews = labelWidget()
return appending { w, ctx in
guard let v = labelWidgetViews.first else { return }
w.setLabelWidget(labelWidget: v.makeWidget(ctx))
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Expander.setLabelWidget(labelWidget:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getLabelWidget()
/// Set the label widget for the expander.
///
/// This is the widget that will appear embedded alongside
/// the expander arrow.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.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 labelWidget<W: Gtk.Widget>(_ labelWidget: Portico.Binding<W?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, labelWidget, registry: ctx.registry, notifyDetail: "label-widget",
read: { [w] in w.getLabelWidget() as? W },
write: { [w] v in w.setLabelWidget(labelWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Expander.setLabelWidget(labelWidget:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getLabelWidget()
/// Set the label widget for the expander.
///
/// This is the widget that will appear embedded alongside
/// the expander arrow.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Widget>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Widget?>` to be able to clear the property.
/// When `Gtk.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 labelWidget<W: Gtk.Widget>(_ labelWidget: Portico.Binding<W>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, labelWidget, registry: ctx.registry, notifyDetail: "label-widget",
read: { [w] in w.getLabelWidget() as? W },
write: { [w] v in w.setLabelWidget(labelWidget: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Expander.setLabelWidget(labelWidget:)
/// Set the label widget for the expander.
///
/// This is the widget that will appear embedded alongside
/// the expander arrow.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setLabelWidget(labelWidget:)`.
///
/// - Parameter labelWidget: A widget to display instead of the usual expander label.
/// - Returns: A copy of this view with the modifier applied.
public func labelWidget(_ labelWidget: @escaping () -> Gtk.Widget?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setLabelWidget(labelWidget: labelWidget()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setResizeToplevel(resizeToplevel:)
/// Sets whether the expander will resize the toplevel widget
/// containing the expander upon resizing and collapsing.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Returns: A copy of this view with the modifier applied.
public func resizeToplevel(_ resizeToplevel: Bool) -> Self {
appending { w, _ in
w.setResizeToplevel(resizeToplevel: resizeToplevel)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Expander.setResizeToplevel(resizeToplevel:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getResizeToplevel()
/// Sets whether the expander will resize the toplevel widget
/// containing the expander upon resizing and collapsing.
///
/// 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 resizeToplevel(_ resizeToplevel: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, resizeToplevel, registry: ctx.registry, notifyDetail: "resize-toplevel",
read: { [w] in w.getResizeToplevel() },
write: { [w] v in w.setResizeToplevel(resizeToplevel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Expander.setResizeToplevel(resizeToplevel:)
/// Sets whether the expander will resize the toplevel widget
/// containing the expander upon resizing and collapsing.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setResizeToplevel(resizeToplevel:)`.
///
/// - Parameter resizeToplevel: When this property is `true`, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
/// - Returns: A copy of this view with the modifier applied.
public func resizeToplevel(_ resizeToplevel: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setResizeToplevel(resizeToplevel: resizeToplevel()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setUseMarkup(useMarkup:)
/// Sets whether the text of the label contains Pango markup.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - Returns: A copy of this view with the modifier applied.
public func useMarkup(_ useMarkup: Bool) -> Self {
appending { w, _ in
w.setUseMarkup(useMarkup: useMarkup)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Expander.setUseMarkup(useMarkup:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getUseMarkup()
/// Sets whether the text of the label contains Pango markup.
///
/// 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 useMarkup(_ useMarkup: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, useMarkup, registry: ctx.registry, notifyDetail: "use-markup",
read: { [w] in w.getUseMarkup() },
write: { [w] v in w.setUseMarkup(useMarkup: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Expander.setUseMarkup(useMarkup:)
/// Sets whether the text of the label contains Pango markup.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.setUseMarkup(useMarkup:)`.
///
/// - Parameter useMarkup: Whether the text in the label is Pango markup.
/// - Returns: A copy of this view with the modifier applied.
public func useMarkup(_ useMarkup: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setUseMarkup(useMarkup: useMarkup()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Expander.setUseUnderline(useUnderline:)
/// If true, an underline in the text indicates a mnemonic.
///
/// 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: Gtk.Expander.setUseUnderline(useUnderline:), GObject.Object.connectNotify(detail:_:), Gtk.Expander.getUseUnderline()
/// If true, an underline in the text indicates a mnemonic.
///
/// 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: Gtk.Expander.setUseUnderline(useUnderline:)
/// If true, an underline in the text indicates a mnemonic.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Expander.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: Gtk.Expander.connectActivate(_:)
/// Activates the `GtkExpander`.
///
/// - 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() })
}
}
}