portico/Sources/Portico/Generated/CellView.swift

350 lines
21 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Gtk.CellView
/// A widget displaying a single row of a GtkTreeModel
///
/// A `GtkCellView` displays a single row of a `GtkTreeModel` using a `GtkCellArea`
/// and `GtkCellAreaContext`. A `GtkCellAreaContext` can be provided to the
/// `GtkCellView` at construction time in order to keep the cellview in context
/// of a group of cell views, this ensures that the renderers displayed will
/// be properly aligned with each other (like the aligned cells in the menus
/// of `GtkComboBox`).
///
/// `GtkCellView` is `GtkOrientable` in order to decide in which orientation
/// the underlying `GtkCellAreaContext` should be allocated. Taking the `GtkComboBox`
/// menu as an example, cellviews should be oriented horizontally if the menus are
/// listed top-to-bottom and thus all share the same width but may have separate
/// individual heights (left-to-right menus should be allocated vertically since
/// they all share the same height but may have variable widths).
///
/// ## CSS nodes
///
/// GtkCellView has a single CSS node with name cellview.
///
/// A Portico view that mounts a `Gtk.CellView`.
@MainActor public struct CellView: View {
private let make: (MountContext) -> Gtk.CellView
private var configure: [(Gtk.CellView, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.CellView.init()
/// Creates a new `GtkCellView` widget.
///
/// 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 drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Parameter model: The model for cell view
public init(drawSensitive: Bool? = nil, fitModel: Bool? = nil, model: Gtk.TreeModel? = nil) {
make = { _ in Gtk.CellView() }
configure.append { w, _ in
if let drawSensitive { w.setDrawSensitive(drawSensitive: drawSensitive) }
if let fitModel { w.setFitModel(fitModel: fitModel) }
if let model { w.setModel(model: model) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CellView.init(area:context:)
/// Creates a new `GtkCellView` widget with a specific `GtkCellArea`
/// to layout cells and a specific `GtkCellAreaContext`.
///
/// Specifying the same context for a handful of cells lets
/// the underlying area synchronize the geometry for those cells,
/// in this way alignments with cellviews for other rows are
/// possible.
///
/// 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 area: The `area` value forwarded to `Gtk.CellView`.
/// - Parameter context: The `context` value forwarded to `Gtk.CellView`.
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Parameter model: The model for cell view
public init(area: Gtk.CellArea, context: Gtk.CellAreaContext, drawSensitive: Bool? = nil, fitModel: Bool? = nil, model: Gtk.TreeModel? = nil) {
make = { _ in Gtk.CellView(area: area, context: context) }
configure.append { w, _ in
if let drawSensitive { w.setDrawSensitive(drawSensitive: drawSensitive) }
if let fitModel { w.setFitModel(fitModel: fitModel) }
if let model { w.setModel(model: model) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CellView.init(markup:)
/// Creates a new `GtkCellView` widget, adds a `GtkCellRendererText`
/// to it, and makes it show `markup`. The text can be marked up with
/// the [Pango text markup language](https://docs.gtk.org/Pango/pango_markup.html).
///
/// 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 markup: The `markup` value forwarded to `Gtk.CellView`.
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Parameter model: The model for cell view
public init(markup: String, drawSensitive: Bool? = nil, fitModel: Bool? = nil, model: Gtk.TreeModel? = nil) {
make = { _ in Gtk.CellView(markup: markup) }
configure.append { w, _ in
if let drawSensitive { w.setDrawSensitive(drawSensitive: drawSensitive) }
if let fitModel { w.setFitModel(fitModel: fitModel) }
if let model { w.setModel(model: model) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CellView.init(text:)
/// Creates a new `GtkCellView` widget, adds a `GtkCellRendererText`
/// to it, and makes it show `text`.
///
/// 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 text: The `text` value forwarded to `Gtk.CellView`.
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Parameter model: The model for cell view
public init(text: String, drawSensitive: Bool? = nil, fitModel: Bool? = nil, model: Gtk.TreeModel? = nil) {
make = { _ in Gtk.CellView(text: text) }
configure.append { w, _ in
if let drawSensitive { w.setDrawSensitive(drawSensitive: drawSensitive) }
if let fitModel { w.setFitModel(fitModel: fitModel) }
if let model { w.setModel(model: model) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.CellView.init(texture:)
/// Creates a new `GtkCellView` widget, adds a `GtkCellRendererPixbuf`
/// to it, and makes it show `texture`.
///
/// 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 texture: The `texture` value forwarded to `Gtk.CellView`.
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Parameter model: The model for cell view
public init(texture: Gtk.Texture, drawSensitive: Bool? = nil, fitModel: Bool? = nil, model: Gtk.TreeModel? = nil) {
make = { _ in Gtk.CellView(texture: texture) }
configure.append { w, _ in
if let drawSensitive { w.setDrawSensitive(drawSensitive: drawSensitive) }
if let fitModel { w.setFitModel(fitModel: fitModel) }
if let model { w.setModel(model: model) }
}
}
}
extension CellView: WidgetView {
public typealias Target = Gtk.CellView
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.CellView, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension CellView: 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.CellView
/// Modifiers for `Gtk.CellView`, available on every Portico view whose
/// backing widget is `Gtk.CellView` or one of its subclasses.
extension WidgetView where Target: Gtk.CellView {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CellView.setDrawSensitive(drawSensitive:)
/// Sets whether `cell_view` should draw all of its
/// cells in a sensitive state, this is used by `GtkComboBox` menus
/// to ensure that rows with insensitive cells that contain
/// children appear sensitive in the parent menu item.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Returns: A copy of this view with the modifier applied.
public func drawSensitive(_ drawSensitive: Bool) -> Self {
appending { w, _ in
w.setDrawSensitive(drawSensitive: drawSensitive)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CellView.setDrawSensitive(drawSensitive:), GObject.Object.connectNotify(detail:_:), Gtk.CellView.getDrawSensitive()
/// Sets whether `cell_view` should draw all of its
/// cells in a sensitive state, this is used by `GtkComboBox` menus
/// to ensure that rows with insensitive cells that contain
/// children appear sensitive in the parent menu item.
///
/// 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 drawSensitive(_ drawSensitive: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, drawSensitive, registry: ctx.registry, notifyDetail: "draw-sensitive",
read: { [w] in w.getDrawSensitive() },
write: { [w] v in w.setDrawSensitive(drawSensitive: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CellView.setDrawSensitive(drawSensitive:)
/// Sets whether `cell_view` should draw all of its
/// cells in a sensitive state, this is used by `GtkComboBox` menus
/// to ensure that rows with insensitive cells that contain
/// children appear sensitive in the parent menu item.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CellView.setDrawSensitive(drawSensitive:)`.
///
/// - Parameter drawSensitive: Whether all cells should be draw as sensitive for this view regardless of the actual cell properties (used to make menus with submenus appear sensitive when the items in submenus might be insensitive).
/// - Returns: A copy of this view with the modifier applied.
public func drawSensitive(_ drawSensitive: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setDrawSensitive(drawSensitive: drawSensitive()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CellView.setFitModel(fitModel:)
/// Sets whether `cell_view` should request space to fit the entire `GtkTreeModel`.
///
/// This is used by `GtkComboBox` to ensure that the cell view displayed on
/// the combo boxs button always gets enough space and does not resize
/// when selection changes.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Returns: A copy of this view with the modifier applied.
public func fitModel(_ fitModel: Bool) -> Self {
appending { w, _ in
w.setFitModel(fitModel: fitModel)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CellView.setFitModel(fitModel:), GObject.Object.connectNotify(detail:_:), Gtk.CellView.getFitModel()
/// Sets whether `cell_view` should request space to fit the entire `GtkTreeModel`.
///
/// This is used by `GtkComboBox` to ensure that the cell view displayed on
/// the combo boxs button always gets enough space and does not resize
/// when selection changes.
///
/// 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 fitModel(_ fitModel: Portico.Binding<Bool>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, fitModel, registry: ctx.registry, notifyDetail: "fit-model",
read: { [w] in w.getFitModel() },
write: { [w] v in w.setFitModel(fitModel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CellView.setFitModel(fitModel:)
/// Sets whether `cell_view` should request space to fit the entire `GtkTreeModel`.
///
/// This is used by `GtkComboBox` to ensure that the cell view displayed on
/// the combo boxs button always gets enough space and does not resize
/// when selection changes.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CellView.setFitModel(fitModel:)`.
///
/// - Parameter fitModel: Whether the view should request enough space to always fit the size of every row in the model (used by the combo box to ensure the combo box size doesn't change when different items are selected).
/// - Returns: A copy of this view with the modifier applied.
public func fitModel(_ fitModel: @escaping () -> Bool) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFitModel(fitModel: fitModel()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.CellView.setModel(model:)
/// Sets the model for `cell_view`. If `cell_view` already has a model
/// set, it will remove it before setting the new model. If `model` is
/// `nil`, then it will unset the old model.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter model: The model for cell view
/// - Returns: A copy of this view with the modifier applied.
public func model(_ model: Gtk.TreeModel?) -> Self {
appending { w, _ in
w.setModel(model: model)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.CellView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.CellView.getModel()
/// Sets the model for `cell_view`. If `cell_view` already has a model
/// set, it will remove it before setting the new model. If `model` is
/// `nil`, then it will unset the old model.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.TreeModel?` 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 model(_ model: Portico.Binding<Gtk.TreeModel?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, model, registry: ctx.registry, notifyDetail: "model",
read: { [w] in w.getModel() },
write: { [w] v in w.setModel(model: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.CellView.setModel(model:), GObject.Object.connectNotify(detail:_:), Gtk.CellView.getModel()
/// Sets the model for `cell_view`. If `cell_view` already has a model
/// set, it will remove it before setting the new model. If `model` is
/// `nil`, then it will unset the old model.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.TreeModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.TreeModel?>` to be able to clear the property.
/// When `Gtk.TreeModel` 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 model(_ model: Portico.Binding<Gtk.TreeModel>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, model, registry: ctx.registry, notifyDetail: "model",
read: { [w] in w.getModel() },
write: { [w] v in w.setModel(model: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.CellView.setModel(model:)
/// Sets the model for `cell_view`. If `cell_view` already has a model
/// set, it will remove it before setting the new model. If `model` is
/// `nil`, then it will unset the old model.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.CellView.setModel(model:)`.
///
/// - Parameter model: The model for cell view
/// - Returns: A copy of this view with the modifier applied.
public func model(_ model: @escaping () -> Gtk.TreeModel?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setModel(model: model()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}