556 lines
28 KiB
Swift
556 lines
28 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.Popover
|
|
/// Presents a bubble-like popup.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="popover-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkPopover" src="popover.png">
|
|
/// </picture>
|
|
///
|
|
/// It is primarily meant to provide context-dependent information
|
|
/// or options. Popovers are attached to a parent widget. The parent widget
|
|
/// must support popover children, as [class`Gtk`.MenuButton] and
|
|
/// [class`Gtk`.PopoverMenuBar] do. If you want to make a custom widget that
|
|
/// has an attached popover, you need to call [method`Gtk`.Popover.present]
|
|
/// in your [vfunc`Gtk`.Widget.size_allocate] vfunc, in order to update the
|
|
/// positioning of the popover.
|
|
///
|
|
/// The position of a popover relative to the widget it is attached to
|
|
/// can also be changed with [method`Gtk`.Popover.set_position]. By default,
|
|
/// it points to the whole widget area, but it can be made to point to
|
|
/// a specific area using [method`Gtk`.Popover.set_pointing_to].
|
|
///
|
|
/// By default, `GtkPopover` performs a grab, in order to ensure input
|
|
/// events get redirected to it while it is shown, and also so the popover
|
|
/// is dismissed in the expected situations (clicks outside the popover,
|
|
/// or the Escape key being pressed). If no such modal behavior is desired
|
|
/// on a popover, [method`Gtk`.Popover.set_autohide] may be called on it to
|
|
/// tweak its behavior.
|
|
///
|
|
/// ## GtkPopover as menu replacement
|
|
///
|
|
/// `GtkPopover` is often used to replace menus. The best way to do this
|
|
/// is to use the [class`Gtk`.PopoverMenu] subclass which supports being
|
|
/// populated from a `GMenuModel` with [ctor`Gtk`.PopoverMenu.new_from_model].
|
|
///
|
|
/// ```xml
|
|
/// <section>
|
|
/// <attribute name="display-hint">horizontal-buttons</attribute>
|
|
/// <item>
|
|
/// <attribute name="label">Cut</attribute>
|
|
/// <attribute name="action">app.cut</attribute>
|
|
/// <attribute name="verb-icon">edit-cut-symbolic</attribute>
|
|
/// </item>
|
|
/// <item>
|
|
/// <attribute name="label">Copy</attribute>
|
|
/// <attribute name="action">app.copy</attribute>
|
|
/// <attribute name="verb-icon">edit-copy-symbolic</attribute>
|
|
/// </item>
|
|
/// <item>
|
|
/// <attribute name="label">Paste</attribute>
|
|
/// <attribute name="action">app.paste</attribute>
|
|
/// <attribute name="verb-icon">edit-paste-symbolic</attribute>
|
|
/// </item>
|
|
/// </section>
|
|
/// ```
|
|
///
|
|
/// # Shortcuts and Gestures
|
|
///
|
|
/// `GtkPopover` supports the following keyboard shortcuts:
|
|
///
|
|
/// - <kbd>Escape</kbd> closes the popover.
|
|
/// - <kbd>Alt</kbd> makes the mnemonics visible.
|
|
///
|
|
/// The following signals have default keybindings:
|
|
///
|
|
/// - [signal`Gtk`.Popover::activate-default]
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// ```
|
|
/// popover.background[.menu]
|
|
/// ├── arrow
|
|
/// ╰── contents
|
|
/// ╰── <child>
|
|
/// ```
|
|
///
|
|
/// `GtkPopover` has a main node with name `popover`, an arrow with name `arrow`,
|
|
/// and another node for the content named `contents`. The `popover` node always
|
|
/// gets the `.background` style class. It also gets the `.menu` style class
|
|
/// if the popover is menu-like, e.g. is a [class`Gtk`.PopoverMenu].
|
|
///
|
|
/// Particular uses of `GtkPopover`, such as touch selection popups or
|
|
/// magnifiers in `GtkEntry` or `GtkTextView` get style classes like
|
|
/// `.touch-selection` or `.magnifier` to differentiate from plain popovers.
|
|
///
|
|
/// When styling a popover directly, the `popover` node should usually
|
|
/// not have any background. The visible part of the popover can have
|
|
/// a shadow. To specify it in CSS, set the box-shadow of the `contents` node.
|
|
///
|
|
/// Note that, in order to accomplish appropriate arrow visuals, `GtkPopover`
|
|
/// uses custom drawing for the `arrow` node. This makes it possible for the
|
|
/// arrow to change its shape dynamically, but it also limits the possibilities
|
|
/// of styling it using CSS. In particular, the `arrow` gets drawn over the
|
|
/// `content` node's border and shadow, so they look like one shape, which
|
|
/// means that the border width of the `content` node and the `arrow` node should
|
|
/// be the same. The arrow also does not support any border shape other than
|
|
/// solid, no border-radius, only one border width (border-bottom-width is
|
|
/// used) and no box-shadow.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Popover`.
|
|
@MainActor public struct Popover: View {
|
|
private let make: (MountContext) -> Gtk.Popover
|
|
private var configure: [(Gtk.Popover, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Popover.init()
|
|
/// Creates a new `GtkPopover`.
|
|
///
|
|
/// 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 autohide: Whether to dismiss the popover on outside clicks.
|
|
/// - Parameter cascadePopdown: Whether the popover pops down after a child popover.
|
|
/// - Parameter hasArrow: Whether to draw an arrow.
|
|
/// - Parameter mnemonicsVisible: Whether mnemonics are currently visible in this popover.
|
|
/// - Parameter position: How to place the popover, relative to its parent.
|
|
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
|
/// - Parameter onActivateDefault: Invoked when the widget emits the `activate-default` signal.
|
|
/// - Parameter onClosed: Invoked when the widget emits the `closed` signal.
|
|
public init(autohide: Bool? = nil, cascadePopdown: Bool? = nil, hasArrow: Bool? = nil, mnemonicsVisible: Bool? = nil, position: Gtk.PositionType? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, onActivateDefault: (() -> Void)? = nil, onClosed: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.Popover() }
|
|
configure.append { w, ctx in
|
|
if let autohide { w.setAutohide(autohide: autohide) }
|
|
if let cascadePopdown { w.setCascadePopdown(cascadePopdown: cascadePopdown) }
|
|
if let hasArrow { w.setHasArrow(hasArrow: hasArrow) }
|
|
if let mnemonicsVisible { w.setMnemonicsVisible(mnemonicsVisible: mnemonicsVisible) }
|
|
if let position { w.setPosition(position: position) }
|
|
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
|
if let onActivateDefault { ctx.registry.add(w.connectActivateDefault { _ in onActivateDefault() }) }
|
|
if let onClosed { ctx.registry.add(w.connectClosed { _ in onClosed() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Popover: WidgetView {
|
|
public typealias Target = Gtk.Popover
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Popover, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Popover: 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.Popover
|
|
/// Modifiers for `Gtk.Popover`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Popover` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Popover {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Popover.setAutohide(autohide:)
|
|
/// Sets whether `popover` is modal.
|
|
///
|
|
/// A modal popover will grab the keyboard focus on it when being
|
|
/// displayed. Focus will wrap around within the popover. Clicking
|
|
/// outside the popover area or pressing Esc will dismiss the popover.
|
|
///
|
|
/// Called this function on an already showing popup with a new
|
|
/// autohide value different from the current one, will cause the
|
|
/// popup to be hidden.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter autohide: Whether to dismiss the popover on outside clicks.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func autohide(_ autohide: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setAutohide(autohide: autohide)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Popover.setAutohide(autohide:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getAutohide()
|
|
/// Sets whether `popover` is modal.
|
|
///
|
|
/// A modal popover will grab the keyboard focus on it when being
|
|
/// displayed. Focus will wrap around within the popover. Clicking
|
|
/// outside the popover area or pressing Esc will dismiss the popover.
|
|
///
|
|
/// Called this function on an already showing popup with a new
|
|
/// autohide value different from the current one, will cause the
|
|
/// popup 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 autohide(_ autohide: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, autohide, registry: ctx.registry, notifyDetail: "autohide",
|
|
read: { [w] in w.getAutohide() },
|
|
write: { [w] v in w.setAutohide(autohide: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Popover.setAutohide(autohide:)
|
|
/// Sets whether `popover` is modal.
|
|
///
|
|
/// A modal popover will grab the keyboard focus on it when being
|
|
/// displayed. Focus will wrap around within the popover. Clicking
|
|
/// outside the popover area or pressing Esc will dismiss the popover.
|
|
///
|
|
/// Called this function on an already showing popup with a new
|
|
/// autohide value different from the current one, will cause the
|
|
/// popup to be hidden.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.setAutohide(autohide:)`.
|
|
///
|
|
/// - Parameter autohide: Whether to dismiss the popover on outside clicks.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func autohide(_ autohide: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setAutohide(autohide: autohide()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Popover.setCascadePopdown(cascadePopdown:)
|
|
/// If `cascade_popdown` is `true`, the popover will be
|
|
/// closed when a child modal popover is closed.
|
|
///
|
|
/// If `false`, `popover` will stay visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter cascadePopdown: Whether the popover pops down after a child popover.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func cascadePopdown(_ cascadePopdown: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setCascadePopdown(cascadePopdown: cascadePopdown)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Popover.setCascadePopdown(cascadePopdown:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getCascadePopdown()
|
|
/// If `cascade_popdown` is `true`, the popover will be
|
|
/// closed when a child modal popover is closed.
|
|
///
|
|
/// If `false`, `popover` will stay visible.
|
|
///
|
|
/// 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 cascadePopdown(_ cascadePopdown: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, cascadePopdown, registry: ctx.registry, notifyDetail: "cascade-popdown",
|
|
read: { [w] in w.getCascadePopdown() },
|
|
write: { [w] v in w.setCascadePopdown(cascadePopdown: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Popover.setCascadePopdown(cascadePopdown:)
|
|
/// If `cascade_popdown` is `true`, the popover will be
|
|
/// closed when a child modal popover is closed.
|
|
///
|
|
/// If `false`, `popover` will stay visible.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.setCascadePopdown(cascadePopdown:)`.
|
|
///
|
|
/// - Parameter cascadePopdown: Whether the popover pops down after a child popover.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func cascadePopdown(_ cascadePopdown: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCascadePopdown(cascadePopdown: cascadePopdown()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Popover.setChild(child:)
|
|
/// Sets the child widget of `popover`.
|
|
///
|
|
/// 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.Popover.setChild(child:)
|
|
/// Sets the child widget of `popover`.
|
|
///
|
|
/// 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.Popover.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getChild()
|
|
/// Sets the child widget of `popover`.
|
|
///
|
|
/// 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.Popover.setChild(child:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getChild()
|
|
/// Sets the child widget of `popover`.
|
|
///
|
|
/// 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.Popover.setChild(child:)
|
|
/// Sets the child widget of `popover`.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.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.Popover.setHasArrow(hasArrow:)
|
|
/// Sets whether this popover should draw an arrow
|
|
/// pointing at the widget it is relative to.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter hasArrow: Whether to draw an arrow.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hasArrow(_ hasArrow: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setHasArrow(hasArrow: hasArrow)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Popover.setHasArrow(hasArrow:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getHasArrow()
|
|
/// Sets whether this popover should draw an arrow
|
|
/// pointing at the widget it is relative to.
|
|
///
|
|
/// 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 hasArrow(_ hasArrow: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, hasArrow, registry: ctx.registry, notifyDetail: "has-arrow",
|
|
read: { [w] in w.getHasArrow() },
|
|
write: { [w] v in w.setHasArrow(hasArrow: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Popover.setHasArrow(hasArrow:)
|
|
/// Sets whether this popover should draw an arrow
|
|
/// pointing at the widget it is relative to.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.setHasArrow(hasArrow:)`.
|
|
///
|
|
/// - Parameter hasArrow: Whether to draw an arrow.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func hasArrow(_ hasArrow: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setHasArrow(hasArrow: hasArrow()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Popover.setMnemonicsVisible(mnemonicsVisible:)
|
|
/// Sets whether mnemonics should be visible.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter mnemonicsVisible: Whether mnemonics are currently visible in this popover.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func mnemonicsVisible(_ mnemonicsVisible: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setMnemonicsVisible(mnemonicsVisible: mnemonicsVisible)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Popover.setMnemonicsVisible(mnemonicsVisible:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getMnemonicsVisible()
|
|
/// Sets whether mnemonics should be visible.
|
|
///
|
|
/// 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 mnemonicsVisible(_ mnemonicsVisible: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, mnemonicsVisible, registry: ctx.registry, notifyDetail: "mnemonics-visible",
|
|
read: { [w] in w.getMnemonicsVisible() },
|
|
write: { [w] v in w.setMnemonicsVisible(mnemonicsVisible: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Popover.setMnemonicsVisible(mnemonicsVisible:)
|
|
/// Sets whether mnemonics should be visible.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.setMnemonicsVisible(mnemonicsVisible:)`.
|
|
///
|
|
/// - Parameter mnemonicsVisible: Whether mnemonics are currently visible in this popover.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func mnemonicsVisible(_ mnemonicsVisible: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setMnemonicsVisible(mnemonicsVisible: mnemonicsVisible()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Popover.setPosition(position:)
|
|
/// Sets the preferred position for `popover` to appear.
|
|
///
|
|
/// If the `popover` is currently visible, it will be immediately
|
|
/// updated.
|
|
///
|
|
/// This preference will be respected where possible, although
|
|
/// on lack of space (eg. if close to the window edges), the
|
|
/// `GtkPopover` may choose to appear on the opposite side.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter position: How to place the popover, relative to its parent.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func position(_ position: Gtk.PositionType) -> Self {
|
|
appending { w, _ in
|
|
w.setPosition(position: position)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Popover.setPosition(position:), GObject.Object.connectNotify(detail:_:), Gtk.Popover.getPosition()
|
|
/// Sets the preferred position for `popover` to appear.
|
|
///
|
|
/// If the `popover` is currently visible, it will be immediately
|
|
/// updated.
|
|
///
|
|
/// This preference will be respected where possible, although
|
|
/// on lack of space (eg. if close to the window edges), the
|
|
/// `GtkPopover` may choose to appear on the opposite side.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.PositionType` 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 position(_ position: Portico.Binding<Gtk.PositionType>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, position, registry: ctx.registry, notifyDetail: "position",
|
|
read: { [w] in w.getPosition() },
|
|
write: { [w] v in w.setPosition(position: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Popover.setPosition(position:)
|
|
/// Sets the preferred position for `popover` to appear.
|
|
///
|
|
/// If the `popover` is currently visible, it will be immediately
|
|
/// updated.
|
|
///
|
|
/// This preference will be respected where possible, although
|
|
/// on lack of space (eg. if close to the window edges), the
|
|
/// `GtkPopover` may choose to appear on the opposite side.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Popover.setPosition(position:)`.
|
|
///
|
|
/// - Parameter position: How to place the popover, relative to its parent.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func position(_ position: @escaping () -> Gtk.PositionType) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setPosition(position: position()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Popover.connectActivateDefault(_:)
|
|
/// Emitted whend the user activates the default widget.
|
|
///
|
|
/// This is a [keybinding signal](class.SignalAction.html).
|
|
///
|
|
/// The default binding for this signal is <kbd>Enter</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `activate-default` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onActivateDefault(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectActivateDefault { _ in handler() })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Popover.connectClosed(_:)
|
|
/// Emitted when the popover is closed.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `closed` signal.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onClosed(_ handler: @escaping () -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectClosed { _ in handler() })
|
|
}
|
|
}
|
|
|
|
}
|