926 lines
50 KiB
Swift
926 lines
50 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.MenuButton
|
|
/// Displays a popup when clicked.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="menu-button-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkMenuButton" src="menu-button.png">
|
|
/// </picture>
|
|
///
|
|
/// This popup can be provided either as a `GtkPopover` or as an abstract
|
|
/// `GMenuModel`.
|
|
///
|
|
/// The `GtkMenuButton` widget can show either an icon (set with the
|
|
/// [property`Gtk`.MenuButton:icon-name] property) or a label (set with the
|
|
/// [property`Gtk`.MenuButton:label] property). If neither is explicitly set,
|
|
/// a [class`Gtk`.Image] is automatically created, using an arrow image oriented
|
|
/// according to [property`Gtk`.MenuButton:direction] or the generic
|
|
/// “open-menu-symbolic” icon if the direction is not set.
|
|
///
|
|
/// The positioning of the popup is determined by the
|
|
/// [property`Gtk`.MenuButton:direction] property of the menu button.
|
|
///
|
|
/// For menus, the [property`Gtk`.Widget:halign] and [property`Gtk`.Widget:valign]
|
|
/// properties of the menu are also taken into account. For example, when the
|
|
/// direction is `GTK_ARROW_DOWN` and the horizontal alignment is `GTK_ALIGN_START`,
|
|
/// the menu will be positioned below the button, with the starting edge
|
|
/// (depending on the text direction) of the menu aligned with the starting
|
|
/// edge of the button. If there is not enough space below the button, the
|
|
/// menu is popped up above the button instead. If the alignment would move
|
|
/// part of the menu offscreen, it is “pushed in”.
|
|
///
|
|
/// | | start | center | end |
|
|
/// | - | --- | --- | --- |
|
|
/// | **down** |  |  |  |
|
|
/// | **up** |  |  |  |
|
|
/// | **left** |  |  |  |
|
|
/// | **right** |  |  |  |
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// ```
|
|
/// menubutton
|
|
/// ╰── button.toggle
|
|
/// ╰── <content>
|
|
/// ╰── [arrow]
|
|
/// ```
|
|
///
|
|
/// `GtkMenuButton` has a single CSS node with name `menubutton`
|
|
/// which contains a `button` node with a `.toggle` style class.
|
|
///
|
|
/// If the button contains an icon, it will have the `.image-button` style class,
|
|
/// if it contains text, it will have `.text-button` style class. If an arrow is
|
|
/// visible in addition to an icon, text or a custom child, it will also have
|
|
/// `.arrow-button` style class.
|
|
///
|
|
/// Inside the toggle button content, there is an `arrow` node for
|
|
/// the indicator, which will carry one of the `.none`, `.up`, `.down`,
|
|
/// `.left` or `.right` style classes to indicate the direction that
|
|
/// the menu will appear in. The CSS is expected to provide a suitable
|
|
/// image for each of these cases using the `-gtk-icon-source` property.
|
|
///
|
|
/// Optionally, the `menubutton` node can carry the `.circular` style class
|
|
/// to request a round appearance.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkMenuButton` uses the [enum`Gtk`.AccessibleRole.button] role.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.MenuButton`.
|
|
@MainActor public struct MenuButton: View {
|
|
private let make: (MountContext) -> Gtk.MenuButton
|
|
private var configure: [(Gtk.MenuButton, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.MenuButton.init()
|
|
/// Creates a new `GtkMenuButton` widget with downwards-pointing
|
|
/// arrow as the only child.
|
|
///
|
|
/// You can replace the child widget with another `GtkWidget`
|
|
/// should you wish to.
|
|
///
|
|
/// 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 active: Whether the menu button is active.
|
|
/// - Parameter alwaysShowArrow: Whether to show a dropdown arrow even when using an icon or a custom child.
|
|
/// - Parameter canShrink: Whether the size of the button can be made smaller than the natural size of its contents.
|
|
/// - Parameter hasFrame: Whether the button has a frame.
|
|
/// - 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 button is clicked.
|
|
/// - Parameter primary: Whether the menu button acts as a primary menu.
|
|
/// - Parameter useUnderline: If set an underscore 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.
|
|
public init(active: Bool? = nil, alwaysShowArrow: Bool? = nil, canShrink: Bool? = nil, hasFrame: Bool? = nil, iconName: String? = nil, label: String? = nil, menuModel: Gtk.MenuModel? = nil, popover: Gtk.Popover? = nil, primary: Bool? = nil, useUnderline: Bool? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivate: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.MenuButton() }
|
|
configure.append { w, ctx in
|
|
if let active { w.setActive(active: active) }
|
|
if let alwaysShowArrow { w.setAlwaysShowArrow(alwaysShowArrow: alwaysShowArrow) }
|
|
if let canShrink { w.setCanShrink(canShrink: canShrink) }
|
|
if let hasFrame { w.setHasFrame(hasFrame: hasFrame) }
|
|
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 primary { w.setPrimary(primary: primary) }
|
|
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() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension MenuButton: WidgetView {
|
|
public typealias Target = Gtk.MenuButton
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.MenuButton, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension MenuButton: 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.MenuButton
|
|
/// Modifiers for `Gtk.MenuButton`, available on every Portico view whose
|
|
/// backing widget is `Gtk.MenuButton` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.MenuButton {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MenuButton.setActive(active:)
|
|
/// Sets whether the menu button is active.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter active: Whether the menu button is active.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func active(_ active: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setActive(active: active)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setActive(active:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getActive()
|
|
/// Sets whether the menu button is active.
|
|
///
|
|
/// 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 active(_ active: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, active, registry: ctx.registry, notifyDetail: "active",
|
|
read: { [w] in w.getActive() },
|
|
write: { [w] v in w.setActive(active: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MenuButton.setActive(active:)
|
|
/// Sets whether the menu button is active.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setActive(active:)`.
|
|
///
|
|
/// - Parameter active: Whether the menu button is active.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func active(_ active: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setActive(active: active()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MenuButton.setAlwaysShowArrow(alwaysShowArrow:)
|
|
/// Sets whether to show a dropdown arrow even when using an icon or a custom
|
|
/// child.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter alwaysShowArrow: Whether to show a dropdown arrow even when using an icon or a custom child.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func alwaysShowArrow(_ alwaysShowArrow: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setAlwaysShowArrow(alwaysShowArrow: alwaysShowArrow)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setAlwaysShowArrow(alwaysShowArrow:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getAlwaysShowArrow()
|
|
/// Sets whether to show a dropdown arrow even when using an icon or a custom
|
|
/// child.
|
|
///
|
|
/// 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 alwaysShowArrow(_ alwaysShowArrow: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, alwaysShowArrow, registry: ctx.registry, notifyDetail: "always-show-arrow",
|
|
read: { [w] in w.getAlwaysShowArrow() },
|
|
write: { [w] v in w.setAlwaysShowArrow(alwaysShowArrow: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MenuButton.setAlwaysShowArrow(alwaysShowArrow:)
|
|
/// Sets whether to show a dropdown arrow even when using an icon or a custom
|
|
/// child.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setAlwaysShowArrow(alwaysShowArrow:)`.
|
|
///
|
|
/// - Parameter alwaysShowArrow: Whether to show a dropdown arrow even when using an icon or a custom child.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func alwaysShowArrow(_ alwaysShowArrow: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setAlwaysShowArrow(alwaysShowArrow: alwaysShowArrow()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MenuButton.setCanShrink(canShrink:)
|
|
/// Sets whether the button size can be smaller than the natural size of
|
|
/// its contents.
|
|
///
|
|
/// For text buttons, setting `can_shrink` to true will ellipsize the label.
|
|
///
|
|
/// For icon buttons, this function has no effect.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter canShrink: Whether the size of the button can be made 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: Gtk.MenuButton.setCanShrink(canShrink:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getCanShrink()
|
|
/// Sets whether the button size can be smaller than the natural size of
|
|
/// its contents.
|
|
///
|
|
/// For text buttons, setting `can_shrink` to true will ellipsize the label.
|
|
///
|
|
/// For icon buttons, this function has no effect.
|
|
///
|
|
/// 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: Gtk.MenuButton.setCanShrink(canShrink:)
|
|
/// Sets whether the button size can be smaller than the natural size of
|
|
/// its contents.
|
|
///
|
|
/// For text buttons, setting `can_shrink` to true will ellipsize the label.
|
|
///
|
|
/// For icon buttons, this function has no effect.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setCanShrink(canShrink:)`.
|
|
///
|
|
/// - Parameter canShrink: Whether the size of the button can be made 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: Gtk.MenuButton.setChild(child:)
|
|
/// Sets the child widget of `menu_button`.
|
|
///
|
|
/// Setting a child resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:icon-name].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the child.
|
|
///
|
|
/// 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.MenuButton.setChild(child:)
|
|
/// Sets the child widget of `menu_button`.
|
|
///
|
|
/// Setting a child resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:icon-name].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the child.
|
|
///
|
|
/// 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.MenuButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getChild()
|
|
/// Sets the child widget of `menu_button`.
|
|
///
|
|
/// Setting a child resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:icon-name].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the child.
|
|
///
|
|
/// 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.MenuButton.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getChild()
|
|
/// Sets the child widget of `menu_button`.
|
|
///
|
|
/// Setting a child resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:icon-name].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the child.
|
|
///
|
|
/// 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.MenuButton.setChild(child:)
|
|
/// Sets the child widget of `menu_button`.
|
|
///
|
|
/// Setting a child resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:icon-name].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the child.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.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.MenuButton.setHasFrame(hasFrame:)
|
|
/// Sets the style of the button.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter hasFrame: Whether the button has a frame.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hasFrame(_ hasFrame: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHasFrame(hasFrame: hasFrame)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setHasFrame(hasFrame:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getHasFrame()
|
|
/// Sets the style of the button.
|
|
///
|
|
/// 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 hasFrame(_ hasFrame: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, hasFrame, registry: ctx.registry, notifyDetail: "has-frame",
|
|
read: { [w] in w.getHasFrame() },
|
|
write: { [w] v in w.setHasFrame(hasFrame: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MenuButton.setHasFrame(hasFrame:)
|
|
/// Sets the style of the button.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setHasFrame(hasFrame:)`.
|
|
///
|
|
/// - Parameter hasFrame: Whether the button has a frame.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hasFrame(_ hasFrame: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHasFrame(hasFrame: hasFrame()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MenuButton.setIconName(iconName:)
|
|
/// Sets the name of an icon to show inside the menu button.
|
|
///
|
|
/// Setting icon name resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the icon.
|
|
///
|
|
/// 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: Gtk.MenuButton.setIconName(iconName:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getIconName()
|
|
/// Sets the name of an icon to show inside the menu button.
|
|
///
|
|
/// Setting icon name resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the icon.
|
|
///
|
|
/// 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: Gtk.MenuButton.setIconName(iconName:)
|
|
/// Sets the name of an icon to show inside the menu button.
|
|
///
|
|
/// Setting icon name resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the icon.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.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: Gtk.MenuButton.setIconName(iconName:)
|
|
/// Sets the name of an icon to show inside the menu button.
|
|
///
|
|
/// Setting icon name resets [property`Gtk`.MenuButton:label] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:always-show-arrow] is set to `TRUE` and
|
|
/// [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown arrow
|
|
/// will be shown next to the icon.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.MenuButton.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: Gtk.MenuButton.setLabel(label:)
|
|
/// Sets the label to show inside the menu button.
|
|
///
|
|
/// Setting a label resets [property`Gtk`.MenuButton:icon-name] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown
|
|
/// arrow will be shown next to the label.
|
|
///
|
|
/// 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: Gtk.MenuButton.setLabel(label:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getLabel()
|
|
/// Sets the label to show inside the menu button.
|
|
///
|
|
/// Setting a label resets [property`Gtk`.MenuButton:icon-name] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown
|
|
/// arrow will be shown next to the label.
|
|
///
|
|
/// 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: Gtk.MenuButton.setLabel(label:)
|
|
/// Sets the label to show inside the menu button.
|
|
///
|
|
/// Setting a label resets [property`Gtk`.MenuButton:icon-name] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown
|
|
/// arrow will be shown next to the label.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.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: Gtk.MenuButton.setLabel(label:)
|
|
/// Sets the label to show inside the menu button.
|
|
///
|
|
/// Setting a label resets [property`Gtk`.MenuButton:icon-name] and
|
|
/// [property`Gtk`.MenuButton:child].
|
|
///
|
|
/// If [property`Gtk`.MenuButton:direction] is not `GTK_ARROW_NONE`, a dropdown
|
|
/// arrow will be shown next to the label.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.MenuButton.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: Gtk.MenuButton.setMenuModel(menuModel:)
|
|
/// Sets the `GMenuModel` from which the popup will be constructed.
|
|
///
|
|
/// If `menu_model` is `nil`, the button 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`Gtk`.MenuButton:popover] is already set, it will be
|
|
/// dissociated from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// 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: Gtk.MenuModel?) -> Self {
|
|
appending { w, _ in
|
|
w.setMenuModel(menuModel: menuModel)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getMenuModel()
|
|
/// Sets the `GMenuModel` from which the popup will be constructed.
|
|
///
|
|
/// If `menu_model` is `nil`, the button 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`Gtk`.MenuButton:popover] is already set, it will be
|
|
/// dissociated from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.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<Gtk.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: Gtk.MenuButton.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getMenuModel()
|
|
/// Sets the `GMenuModel` from which the popup will be constructed.
|
|
///
|
|
/// If `menu_model` is `nil`, the button 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`Gtk`.MenuButton:popover] is already set, it will be
|
|
/// dissociated from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.MenuModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.MenuModel?>` to be able to clear the property.
|
|
/// When `Gtk.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<Gtk.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: Gtk.MenuButton.setMenuModel(menuModel:)
|
|
/// Sets the `GMenuModel` from which the popup will be constructed.
|
|
///
|
|
/// If `menu_model` is `nil`, the button 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`Gtk`.MenuButton:popover] is already set, it will be
|
|
/// dissociated from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.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 () -> Gtk.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: Gtk.MenuButton.setPopover(popover:)
|
|
/// Sets the `GtkPopover` that will be popped up when the `menu_button` is clicked.
|
|
///
|
|
/// If `popover` is `nil`, the button is disabled.
|
|
///
|
|
/// If [property`Gtk`.MenuButton:menu-model] is set, the menu model is dissociated
|
|
/// from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// 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 button is clicked.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func popover(_ popover: Gtk.Popover?) -> Self {
|
|
appending { w, _ in
|
|
w.setPopover(popover: popover)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setPopover(popover:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getPopover()
|
|
/// Sets the `GtkPopover` that will be popped up when the `menu_button` is clicked.
|
|
///
|
|
/// If `popover` is `nil`, the button is disabled.
|
|
///
|
|
/// If [property`Gtk`.MenuButton:menu-model] is set, the menu model is dissociated
|
|
/// from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.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<W: Gtk.Popover>(_ popover: Portico.Binding<W?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, popover, registry: ctx.registry, notifyDetail: "popover",
|
|
read: { [w] in w.getPopover() as? W },
|
|
write: { [w] v in w.setPopover(popover: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.MenuButton.setPopover(popover:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getPopover()
|
|
/// Sets the `GtkPopover` that will be popped up when the `menu_button` is clicked.
|
|
///
|
|
/// If `popover` is `nil`, the button is disabled.
|
|
///
|
|
/// If [property`Gtk`.MenuButton:menu-model] is set, the menu model is dissociated
|
|
/// from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<Gtk.Popover>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Popover?>` to be able to clear the property.
|
|
/// When `Gtk.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<W: Gtk.Popover>(_ popover: Portico.Binding<W>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, popover, registry: ctx.registry, notifyDetail: "popover",
|
|
read: { [w] in w.getPopover() as? W },
|
|
write: { [w] v in w.setPopover(popover: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MenuButton.setPopover(popover:)
|
|
/// Sets the `GtkPopover` that will be popped up when the `menu_button` is clicked.
|
|
///
|
|
/// If `popover` is `nil`, the button is disabled.
|
|
///
|
|
/// If [property`Gtk`.MenuButton:menu-model] is set, the menu model is dissociated
|
|
/// from the `menu_button`, and the property is set to `nil`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setPopover(popover:)`.
|
|
///
|
|
/// - Parameter popover: The `GtkPopover` that will be popped up when the button is clicked.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func popover(_ popover: @escaping () -> Gtk.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: Gtk.MenuButton.setPrimary(primary:)
|
|
/// Sets whether menu button acts as a primary menu.
|
|
///
|
|
/// Primary menus can be opened with the <kbd>F10</kbd> key.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter primary: Whether the menu button acts as a primary menu.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func primary(_ primary: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setPrimary(primary: primary)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.MenuButton.setPrimary(primary:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.getPrimary()
|
|
/// Sets whether menu button acts as a primary menu.
|
|
///
|
|
/// Primary menus can be opened with the <kbd>F10</kbd> key.
|
|
///
|
|
/// 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 primary(_ primary: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, primary, registry: ctx.registry, notifyDetail: "primary",
|
|
read: { [w] in w.getPrimary() },
|
|
write: { [w] v in w.setPrimary(primary: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.MenuButton.setPrimary(primary:)
|
|
/// Sets whether menu button acts as a primary menu.
|
|
///
|
|
/// Primary menus can be opened with the <kbd>F10</kbd> key.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.MenuButton.setPrimary(primary:)`.
|
|
///
|
|
/// - Parameter primary: Whether the menu button acts as a primary menu.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func primary(_ primary: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setPrimary(primary: primary()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.MenuButton.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: If set an underscore 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.MenuButton.setUseUnderline(useUnderline:), GObject.Object.connectNotify(detail:_:), Gtk.MenuButton.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.MenuButton.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.MenuButton.setUseUnderline(useUnderline:)`.
|
|
///
|
|
/// - Parameter useUnderline: If set an underscore 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.MenuButton.connectActivate(_:)
|
|
/// Emitted to when the menu button is activated.
|
|
///
|
|
/// The `::activate` signal on `GtkMenuButton` is an action signal and
|
|
/// emitting it causes the button to pop up its menu.
|
|
///
|
|
/// - 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() })
|
|
}
|
|
}
|
|
|
|
}
|