portico/Sources/Portico/Generated/Image.swift

665 lines
37 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.Image
/// Displays an image.
///
/// <picture>
/// <source srcset="image-dark.png" media="(prefers-color-scheme: dark)">
/// <img alt="An example GtkImage" src="image.png">
/// </picture>
///
/// Various kinds of object can be displayed as an image; most typically,
/// you would load a `GdkTexture` from a file, using the convenience function
/// [ctor`Gtk`.Image.new_from_file], for instance:
///
/// ```c
/// GtkWidget *image = gtk_image_new_from_file ("myfile.png");
/// ```
///
/// If the file isnt loaded successfully, the image will contain a
/// broken image icon similar to that used in many web browsers.
///
/// If you want to handle errors in loading the file yourself, for example
/// by displaying an error message, then load the image with an image
/// loading framework such as libglycin, then create the `GtkImage` with
/// [ctor`Gtk`.Image.new_from_paintable].
///
/// Sometimes an application will want to avoid depending on external data
/// files, such as image files. See the documentation of `GResource` inside
/// GIO, for details. In this case, [property`Gtk`.Image:resource],
/// [ctor`Gtk`.Image.new_from_resource], and [method`Gtk`.Image.set_from_resource]
/// should be used.
///
/// `GtkImage` displays its image as an icon, with a size that is determined
/// by the application. See [class`Gtk`.Picture] if you want to show an image
/// at is actual size.
///
/// ## CSS nodes
///
/// `GtkImage` has a single CSS node with the name `image`. The style classes
/// `.normal-icons` or `.large-icons` may appear, depending on the
/// [property`Gtk`.Image:icon-size] property.
///
/// ## Accessibility
///
/// `GtkImage` uses the [enum`Gtk`.AccessibleRole.img] role.
///
/// A Portico view that mounts a `Gtk.Image`.
@MainActor public struct Image: View {
private let make: (MountContext) -> Gtk.Image
private var configure: [(Gtk.Image, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Gtk.Image.init()
/// Creates a new empty `GtkImage` 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 iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image() }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(filename:)
/// Creates a new `GtkImage` displaying the file `filename`.
///
/// If the file isnt found or cant be loaded, the resulting `GtkImage`
/// will display a broken image icon. This function never returns `nil`,
/// it always returns a valid `GtkImage` widget.
///
/// If you need to detect failures to load the file, use an
/// image loading framework such as libglycin to load the file
/// yourself, then create the `GtkImage` from the texture.
///
/// The storage type (see [method`Gtk`.Image.get_storage_type])
/// of the returned image is not defined, it will be whatever
/// is appropriate for displaying the file.
///
/// 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 filename: The `filename` value forwarded to `Gtk.Image`.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(filename: String, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(filename: filename) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(icon:)
/// Creates a `GtkImage` displaying an icon from the current icon theme.
///
/// If the icon name isnt known, a broken image icon will be
/// displayed instead. If the current icon theme is changed, the icon
/// will be updated appropriately.
///
/// 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 icon: The `icon` value forwarded to `Gtk.Image`.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(icon: Gtk.Icon, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(icon: icon) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(iconName:)
/// Creates a `GtkImage` displaying an icon from the current icon theme.
///
/// If the icon name isnt known, a broken image icon will be
/// displayed instead. If the current icon theme is changed, the icon
/// will be updated appropriately.
///
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for values that change.
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
/// 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 iconName: The name of the icon in the icon theme.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
@_disfavoredOverload
public init<S: StringProtocol>(iconName: S?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(iconName: iconName.map { String($0) }) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.Image.init(iconName:), Gtk.Image.setFromIconName(iconName:)
/// Creates a `GtkImage` displaying an icon from the current icon theme.
///
/// If the icon name isnt known, a broken image icon will be
/// displayed instead. If the current icon theme is changed, the icon
/// will be updated appropriately.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.Image.setFromIconName(iconName:)` without rebuilding the view.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter iconName: The name of the icon in the icon theme.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(iconName: Portico.Binding<String?>, iconSize: Portico.Binding<Gtk.IconSize>? = nil, pixelSize: Portico.Binding<Int32>? = nil) {
make = { _ in Gtk.Image(iconName: iconName.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(iconName.subscribe { [w] v in w.setFromIconName(iconName: v) })
if let iconSize {
Portico.bindProperty(w, iconSize, registry: ctx.registry, notifyDetail: "icon-size", read: { [w] in w.getIconSize() }, write: { [w] v in w.setIconSize(iconSize: v) })
}
if let pixelSize {
Portico.bindProperty(w, pixelSize, registry: ctx.registry, notifyDetail: "pixel-size", read: { [w] in w.getPixelSize() }, write: { [w] v in w.setPixelSize(pixelSize: v) })
}
}
}
// PorticoGen: generateInits(closure) | source: Gtk.Image.init(iconName:), Gtk.Image.setFromIconName(iconName:)
/// Creates a `GtkImage` displaying an icon from the current icon theme.
///
/// If the icon name isnt known, a broken image icon will be
/// displayed instead. If the current icon theme is changed, the icon
/// will be updated appropriately.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setFromIconName(iconName:)`.
/// 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 iconName: The name of the icon in the icon theme.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(iconName: @escaping () -> String?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(iconName: iconName()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setFromIconName(iconName: iconName()) }
t0.run()
ctx.registry.add(t0)
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(interpolation) | source: Gtk.Image.init(iconName:), Gtk.Image.setFromIconName(iconName:)
/// Creates a `GtkImage` displaying an icon from the current icon theme.
///
/// If the icon name isnt known, a broken image icon will be
/// displayed instead. If the current icon theme is changed, the icon
/// will be updated appropriately.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Image.setFromIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
/// 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 iconName: The name of the icon in the icon theme.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(iconName: Portico.InterpolatedText?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(iconName: iconName?.untrackedText) }
configure.append { w, ctx in
Portico.bindOptionalInterpolation(iconName, registry: ctx.registry) { [w] v in w.setFromIconName(iconName: v) }
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(paintable:)
/// Creates a new `GtkImage` displaying `paintable`.
///
/// The `GtkImage` does not assume a reference to the paintable; you still
/// need to unref it if you own references. `GtkImage` will add its own
/// reference rather than adopting yours.
///
/// The `GtkImage` will track changes to the `paintable` and update
/// its size and contents in response to it.
///
/// Note that paintables are still subject to the icon size that is
/// set on the image. If you want to display a paintable at its intrinsic
/// size, use [class`Gtk`.Picture] instead.
///
/// If `paintable` is a [iface`Gtk`.SymbolicPaintable], then it will be
/// recolored with the symbolic palette from the theme.
///
/// 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 paintable: The `GdkPaintable` to display.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(paintable: Gtk.Paintable?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(paintable: paintable) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(binding) | source: Gtk.Image.init(paintable:), Gtk.Image.setFromPaintable(paintable:)
/// Creates a new `GtkImage` displaying `paintable`.
///
/// The `GtkImage` does not assume a reference to the paintable; you still
/// need to unref it if you own references. `GtkImage` will add its own
/// reference rather than adopting yours.
///
/// The `GtkImage` will track changes to the `paintable` and update
/// its size and contents in response to it.
///
/// Note that paintables are still subject to the icon size that is
/// set on the image. If you want to display a paintable at its intrinsic
/// size, use [class`Gtk`.Picture] instead.
///
/// If `paintable` is a [iface`Gtk`.SymbolicPaintable], then it will be
/// recolored with the symbolic palette from the theme.
///
/// The initial value is the binding's current value; every later change is pushed into the widget through `Gtk.Image.setFromPaintable(paintable:)` without rebuilding the view.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
/// Optional `Binding` parameters bind through `Portico.bindProperty`, so they are two-way wherever the wrapper exposes a safe getter.
///
/// - Parameter paintable: The `GdkPaintable` to display.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(paintable: Portico.Binding<Gtk.Paintable?>, iconSize: Portico.Binding<Gtk.IconSize>? = nil, pixelSize: Portico.Binding<Int32>? = nil) {
make = { _ in Gtk.Image(paintable: paintable.wrappedValue) }
configure.append { w, ctx in
ctx.registry.add(paintable.subscribe { [w] v in w.setFromPaintable(paintable: v) })
if let iconSize {
Portico.bindProperty(w, iconSize, registry: ctx.registry, notifyDetail: "icon-size", read: { [w] in w.getIconSize() }, write: { [w] v in w.setIconSize(iconSize: v) })
}
if let pixelSize {
Portico.bindProperty(w, pixelSize, registry: ctx.registry, notifyDetail: "pixel-size", read: { [w] in w.getPixelSize() }, write: { [w] v in w.setPixelSize(pixelSize: v) })
}
}
}
// PorticoGen: generateInits(closure) | source: Gtk.Image.init(paintable:), Gtk.Image.setFromPaintable(paintable:)
/// Creates a new `GtkImage` displaying `paintable`.
///
/// The `GtkImage` does not assume a reference to the paintable; you still
/// need to unref it if you own references. `GtkImage` will add its own
/// reference rather than adopting yours.
///
/// The `GtkImage` will track changes to the `paintable` and update
/// its size and contents in response to it.
///
/// Note that paintables are still subject to the icon size that is
/// set on the image. If you want to display a paintable at its intrinsic
/// size, use [class`Gtk`.Picture] instead.
///
/// If `paintable` is a [iface`Gtk`.SymbolicPaintable], then it will be
/// recolored with the symbolic palette from the theme.
///
/// Each closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setFromPaintable(paintable:)`.
/// 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 paintable: The `GdkPaintable` to display.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(paintable: @escaping () -> Gtk.Paintable?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(paintable: paintable()) }
configure.append { w, ctx in
let t0 = DependencyTracker { [w] in w.setFromPaintable(paintable: paintable()) }
t0.run()
ctx.registry.add(t0)
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(pixbuf:)
/// Creates a new `GtkImage` displaying `pixbuf`.
///
/// The `GtkImage` does not assume a reference to the pixbuf; you still
/// need to unref it if you own references. `GtkImage` will add its own
/// reference rather than adopting yours.
///
/// This is a helper for [ctor`Gtk`.Image.new_from_paintable], and you can't
/// get back the exact pixbuf once this is called, only a texture.
///
/// Note that this function just creates an `GtkImage` from the pixbuf.
/// The `GtkImage` created will not react to state changes. Should you
/// want that, you should use [ctor`Gtk`.Image.new_from_icon_name].
///
/// 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 pixbuf: The `pixbuf` value forwarded to `Gtk.Image`.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(pixbuf: Gtk.Pixbuf?, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(pixbuf: pixbuf) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
// PorticoGen: generateInits(static) | source: Gtk.Image.init(resourcePath:)
/// Creates a new `GtkImage` displaying the resource file `resource_path`.
///
/// If the file isnt found or cant be loaded, the resulting `GtkImage` will
/// display a broken image icon. This function never returns `nil`,
/// it always returns a valid `GtkImage` widget.
///
/// If you need to detect failures to load the file, use an
/// image loading framework such as libglycin to load the file
/// yourself, then create the `GtkImage` from the texture.
///
/// The storage type (see [method`Gtk`.Image.get_storage_type]) of
/// the returned image is not defined, it will be whatever is
/// appropriate for displaying the file.
///
/// 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 resourcePath: The `resourcePath` value forwarded to `Gtk.Image`.
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Parameter pixelSize: The size in pixels to display icons at.
public init(resourcePath: String, iconSize: Gtk.IconSize? = nil, pixelSize: Int32? = nil) {
make = { _ in Gtk.Image(resourcePath: resourcePath) }
configure.append { w, _ in
if let iconSize { w.setIconSize(iconSize: iconSize) }
if let pixelSize { w.setPixelSize(pixelSize: pixelSize) }
}
}
}
extension Image: WidgetView {
public typealias Target = Gtk.Image
@_spi(Portico) public func appending(
_ step: @escaping (Gtk.Image, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension Image: 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.Image
/// Modifiers for `Gtk.Image`, available on every Portico view whose
/// backing widget is `Gtk.Image` or one of its subclasses.
extension WidgetView where Target: Gtk.Image {
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Image.setFromIconName(iconName:)
/// Sets a `GtkImage` to show a named icon.
///
/// See [ctor`Gtk`.Image.new_from_icon_name] for details.
///
/// 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 in the icon theme.
/// - Returns: A copy of this view with the modifier applied.
@_disfavoredOverload
public func iconName<S: StringProtocol>(_ iconName: S?) -> Self {
appending { w, _ in
w.setFromIconName(iconName: iconName.map { String($0) })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Image.setFromIconName(iconName:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getIconName()
/// Sets a `GtkImage` to show a named icon.
///
/// See [ctor`Gtk`.Image.new_from_icon_name] for details.
///
/// 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.setFromIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Image.setFromIconName(iconName:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getIconName()
/// Sets a `GtkImage` to show a named icon.
///
/// See [ctor`Gtk`.Image.new_from_icon_name] for details.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func 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.setFromIconName(iconName: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Image.setFromIconName(iconName:)
/// Sets a `GtkImage` to show a named icon.
///
/// See [ctor`Gtk`.Image.new_from_icon_name] for details.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setFromIconName(iconName:)`.
///
/// - Parameter iconName: The name of the icon in the icon theme.
/// - 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.setFromIconName(iconName: iconName()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.Image.setFromIconName(iconName:)
/// Sets a `GtkImage` to show a named icon.
///
/// See [ctor`Gtk`.Image.new_from_icon_name] for details.
///
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Image.setFromIconName(iconName:)`. A literal with no interpolation is applied once, with no subscription.
///
/// - Parameter iconName: The name of the icon in the icon theme.
/// - Returns: A copy of this view with the modifier applied.
public func iconName(_ iconName: Portico.InterpolatedText?) -> Self {
appending { w, ctx in
Portico.bindOptionalInterpolation(iconName, registry: ctx.registry) { [w] v in w.setFromIconName(iconName: v) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Image.setIconSize(iconSize:)
/// Suggests an icon size to the theme for named icons.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Returns: A copy of this view with the modifier applied.
public func iconSize(_ iconSize: Gtk.IconSize) -> Self {
appending { w, _ in
w.setIconSize(iconSize: iconSize)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Image.setIconSize(iconSize:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getIconSize()
/// Suggests an icon size to the theme for named icons.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.IconSize` 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 iconSize(_ iconSize: Portico.Binding<Gtk.IconSize>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, iconSize, registry: ctx.registry, notifyDetail: "icon-size",
read: { [w] in w.getIconSize() },
write: { [w] v in w.setIconSize(iconSize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Image.setIconSize(iconSize:)
/// Suggests an icon size to the theme for named icons.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setIconSize(iconSize:)`.
///
/// - Parameter iconSize: The symbolic size to display icons at.
/// - Returns: A copy of this view with the modifier applied.
public func iconSize(_ iconSize: @escaping () -> Gtk.IconSize) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setIconSize(iconSize: iconSize()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Image.setFromPaintable(paintable:)
/// Sets a `GtkImage` to show a `GdkPaintable`.
///
/// See [ctor`Gtk`.Image.new_from_paintable] for details.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter paintable: The `GdkPaintable` to display.
/// - Returns: A copy of this view with the modifier applied.
public func paintable(_ paintable: Gtk.Paintable?) -> Self {
appending { w, _ in
w.setFromPaintable(paintable: paintable)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Image.setFromPaintable(paintable:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getPaintable()
/// Sets a `GtkImage` to show a `GdkPaintable`.
///
/// See [ctor`Gtk`.Image.new_from_paintable] for details.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Gtk.Paintable?` 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 paintable(_ paintable: Portico.Binding<Gtk.Paintable?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, paintable, registry: ctx.registry, notifyDetail: "paintable",
read: { [w] in w.getPaintable() },
write: { [w] v in w.setFromPaintable(paintable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Image.setFromPaintable(paintable:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getPaintable()
/// Sets a `GtkImage` to show a `GdkPaintable`.
///
/// See [ctor`Gtk`.Image.new_from_paintable] for details.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Gtk.Paintable>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Gtk.Paintable?>` to be able to clear the property.
/// When `Gtk.Paintable` 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 paintable(_ paintable: Portico.Binding<Gtk.Paintable>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, paintable, registry: ctx.registry, notifyDetail: "paintable",
read: { [w] in w.getPaintable() },
write: { [w] v in w.setFromPaintable(paintable: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Image.setFromPaintable(paintable:)
/// Sets a `GtkImage` to show a `GdkPaintable`.
///
/// See [ctor`Gtk`.Image.new_from_paintable] for details.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setFromPaintable(paintable:)`.
///
/// - Parameter paintable: The `GdkPaintable` to display.
/// - Returns: A copy of this view with the modifier applied.
public func paintable(_ paintable: @escaping () -> Gtk.Paintable?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setFromPaintable(paintable: paintable()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Image.setPixelSize(pixelSize:)
/// Sets the pixel size to use for named icons.
///
/// If the pixel size is set to a value != -1, it is used instead
/// of the icon size set by [method`Gtk`.Image.set_icon_size].
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter pixelSize: The size in pixels to display icons at.
/// - Returns: A copy of this view with the modifier applied.
public func pixelSize(_ pixelSize: Int32) -> Self {
appending { w, _ in
w.setPixelSize(pixelSize: pixelSize)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Image.setPixelSize(pixelSize:), GObject.Object.connectNotify(detail:_:), Gtk.Image.getPixelSize()
/// Sets the pixel size to use for named icons.
///
/// If the pixel size is set to a value != -1, it is used instead
/// of the icon size set by [method`Gtk`.Image.set_icon_size].
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Int32` 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 pixelSize(_ pixelSize: Portico.Binding<Int32>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, pixelSize, registry: ctx.registry, notifyDetail: "pixel-size",
read: { [w] in w.getPixelSize() },
write: { [w] v in w.setPixelSize(pixelSize: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Image.setPixelSize(pixelSize:)
/// Sets the pixel size to use for named icons.
///
/// If the pixel size is set to a value != -1, it is used instead
/// of the icon size set by [method`Gtk`.Image.set_icon_size].
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Image.setPixelSize(pixelSize:)`.
///
/// - Parameter pixelSize: The size in pixels to display icons at.
/// - Returns: A copy of this view with the modifier applied.
public func pixelSize(_ pixelSize: @escaping () -> Int32) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setPixelSize(pixelSize: pixelSize()) }
tracker.run()
ctx.registry.add(tracker)
}
}
}