120 lines
5.4 KiB
Swift
120 lines
5.4 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.Statusbar
|
||
/// A `GtkStatusbar` widget is usually placed along the bottom of an application's
|
||
/// main [class`Gtk`.Window].
|
||
///
|
||
/// <picture>
|
||
/// <source srcset="statusbar-dark.png" media="(prefers-color-scheme: dark)">
|
||
/// <img alt="An example GtkStatusbar" src="statusbar.png">
|
||
/// </picture>
|
||
///
|
||
/// A `GtkStatusBar` may provide a regular commentary of the application's
|
||
/// status (as is usually the case in a web browser, for example), or may be
|
||
/// used to simply output a message when the status changes, (when an upload
|
||
/// is complete in an FTP client, for example).
|
||
///
|
||
/// Status bars in GTK maintain a stack of messages. The message at
|
||
/// the top of the each bar’s stack is the one that will currently be displayed.
|
||
///
|
||
/// Any messages added to a statusbar’s stack must specify a context id that
|
||
/// is used to uniquely identify the source of a message. This context id can
|
||
/// be generated by [method`Gtk`.Statusbar.get_context_id], given a message and
|
||
/// the statusbar that it will be added to. Note that messages are stored in a
|
||
/// stack, and when choosing which message to display, the stack structure is
|
||
/// adhered to, regardless of the context identifier of a message.
|
||
///
|
||
/// One could say that a statusbar maintains one stack of messages for
|
||
/// display purposes, but allows multiple message producers to maintain
|
||
/// sub-stacks of the messages they produced (via context ids).
|
||
///
|
||
/// Status bars are created using [ctor`Gtk`.Statusbar.new].
|
||
///
|
||
/// Messages are added to the bar’s stack with [method`Gtk`.Statusbar.push].
|
||
///
|
||
/// The message at the top of the stack can be removed using
|
||
/// [method`Gtk`.Statusbar.pop]. A message can be removed from anywhere in the
|
||
/// stack if its message id was recorded at the time it was added. This is done
|
||
/// using [method`Gtk`.Statusbar.remove].
|
||
///
|
||
/// ## CSS node
|
||
///
|
||
/// `GtkStatusbar` has a single CSS node with name `statusbar`.
|
||
///
|
||
/// A Portico view that mounts a `Gtk.Statusbar`.
|
||
@MainActor public struct Statusbar: View {
|
||
private let make: (MountContext) -> Gtk.Statusbar
|
||
private var configure: [(Gtk.Statusbar, MountContext) -> Void] = []
|
||
|
||
public var body: Never { fatalError() }
|
||
|
||
// PorticoGen: generateInits(static) | source: Gtk.Statusbar.init()
|
||
/// Creates a new `GtkStatusbar` ready for messages.
|
||
///
|
||
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
||
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
||
///
|
||
/// - Parameter onTextPopped: Invoked when the widget emits the `text-popped` signal. The closure receives the signal's arguments in order.
|
||
/// - Parameter onTextPushed: Invoked when the widget emits the `text-pushed` signal. The closure receives the signal's arguments in order.
|
||
public init(onTextPopped: ((UInt32, String) -> Void)? = nil, onTextPushed: ((UInt32, String) -> Void)? = nil) {
|
||
make = { _ in Gtk.Statusbar() }
|
||
configure.append { w, ctx in
|
||
if let onTextPopped { ctx.registry.add(w.connectTextPopped { _, a0, a1 in onTextPopped(a0, a1) }) }
|
||
if let onTextPushed { ctx.registry.add(w.connectTextPushed { _, a0, a1 in onTextPushed(a0, a1) }) }
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
extension Statusbar: WidgetView {
|
||
public typealias Target = Gtk.Statusbar
|
||
|
||
@_spi(Portico) public func appending(
|
||
_ step: @escaping (Gtk.Statusbar, MountContext) -> Void
|
||
) -> Self {
|
||
var c = self
|
||
c.configure.append(step)
|
||
return c
|
||
}
|
||
}
|
||
|
||
@_spi(Portico) extension Statusbar: 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.Statusbar
|
||
/// Modifiers for `Gtk.Statusbar`, available on every Portico view whose
|
||
/// backing widget is `Gtk.Statusbar` or one of its subclasses.
|
||
extension WidgetView where Target: Gtk.Statusbar {
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Statusbar.connectTextPopped(_:)
|
||
/// Emitted whenever a new message is popped off a statusbar's stack.
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `text-popped` signal. The closure receives the signal's arguments in order.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onTextPopped(_ handler: @escaping (UInt32, String) -> Void) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectTextPopped { _, a0, a1 in handler(a0, a1) })
|
||
}
|
||
}
|
||
|
||
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Statusbar.connectTextPushed(_:)
|
||
/// Emitted whenever a new message gets pushed onto a statusbar's stack.
|
||
///
|
||
/// - Parameter handler: Invoked when the widget emits the `text-pushed` signal. The closure receives the signal's arguments in order.
|
||
/// - Returns: A copy of this view with the modifier applied.
|
||
public func onTextPushed(_ handler: @escaping (UInt32, String) -> Void) -> Self {
|
||
appending { w, ctx in
|
||
ctx.registry.add(w.connectTextPushed { _, a0, a1 in handler(a0, a1) })
|
||
}
|
||
}
|
||
|
||
}
|