Add support for navigation views

This commit is contained in:
david-swift 2024-02-17 14:32:37 +01:00
parent 7019c98a2e
commit 279219ea6c
70 changed files with 1103 additions and 240 deletions

View File

@ -50,6 +50,8 @@
- [MenuSection](structs/MenuSection.md) - [MenuSection](structs/MenuSection.md)
- [ModifierStopper](structs/ModifierStopper.md) - [ModifierStopper](structs/ModifierStopper.md)
- [NavigationSplitView](structs/NavigationSplitView.md) - [NavigationSplitView](structs/NavigationSplitView.md)
- [NavigationView](structs/NavigationView.md)
- [NavigationView.NavigationStack](structs/NavigationView.NavigationStack.md)
- [Overlay](structs/Overlay.md) - [Overlay](structs/Overlay.md)
- [OverlaySplitView](structs/OverlaySplitView.md) - [OverlaySplitView](structs/OverlaySplitView.md)
- [PasswordEntryRow](structs/PasswordEntryRow.md) - [PasswordEntryRow](structs/PasswordEntryRow.md)
@ -99,7 +101,9 @@
- [Edge](enums/Edge.md) - [Edge](enums/Edge.md)
- [Icon](enums/Icon.md) - [Icon](enums/Icon.md)
- [Icon.DefaultIcon](enums/Icon.DefaultIcon.md) - [Icon.DefaultIcon](enums/Icon.DefaultIcon.md)
- [NavigationView.Action](enums/NavigationView.Action.md)
- [Transition](enums/Transition.md) - [Transition](enums/Transition.md)
- [UpdateManager](enums/UpdateManager.md)
- [ViewBuilder](enums/ViewBuilder.md) - [ViewBuilder](enums/ViewBuilder.md)
- [ViewBuilder.Component](enums/ViewBuilder.Component.md) - [ViewBuilder.Component](enums/ViewBuilder.Component.md)
@ -123,6 +127,7 @@
- [Menu](extensions/Menu.md) - [Menu](extensions/Menu.md)
- [MenuItem](extensions/MenuItem.md) - [MenuItem](extensions/MenuItem.md)
- [MenuItemGroup](extensions/MenuItemGroup.md) - [MenuItemGroup](extensions/MenuItemGroup.md)
- [NavigationView](extensions/NavigationView.md)
- [OpaquePointer](extensions/OpaquePointer.md) - [OpaquePointer](extensions/OpaquePointer.md)
- [OverlaySplitView](extensions/OverlaySplitView.md) - [OverlaySplitView](extensions/OverlaySplitView.md)
- [PasswordEntryRow](extensions/PasswordEntryRow.md) - [PasswordEntryRow](extensions/PasswordEntryRow.md)
@ -154,6 +159,7 @@
- [List](typealiases/List.md) - [List](typealiases/List.md)
- [MenuBuilder](typealiases/MenuBuilder.md) - [MenuBuilder](typealiases/MenuBuilder.md)
- [MenuContent](typealiases/MenuContent.md) - [MenuContent](typealiases/MenuContent.md)
- [NavigationStack](typealiases/NavigationStack.md)
- [Scene](typealiases/Scene.md) - [Scene](typealiases/Scene.md)
- [SceneBuilder](typealiases/SceneBuilder.md) - [SceneBuilder](typealiases/SceneBuilder.md)
- [ScrollView](typealiases/ScrollView.md) - [ScrollView](typealiases/ScrollView.md)

View File

@ -0,0 +1,14 @@
**ENUM**
# `NavigationView.Action`
An action to run on a view update.
## Cases
### `pop`
Remove the last item.
### `push(component:)`
Add a new item.

View File

@ -0,0 +1,16 @@
**ENUM**
# `UpdateManager`
This type manages view updates.
## Properties
### `blockUpdates`
The class storing the value.
## Methods
### `updateViews(force:)`
Update all of the views.
- Parameter force: Whether to force all views to update.

View File

@ -0,0 +1,18 @@
**EXTENSION**
# `NavigationView`
## Properties
### `componentID`
The ID for the component field in a content storage.
## Methods
### `init(_:_:content:initialView:)`
Initialize a navigation view.
- Parameters:
- stack: The navigation stack for pushing and popping.
- initialTitle: The title of the initial view.
- content: The view for a path component.
- initialView: The view that is displayed when the path is empty.

View File

@ -34,7 +34,7 @@ visited. In this case, label node also gets a .link style class.
The GtkLabel implementation of the GtkBuildable interface supports a The GtkLabel implementation of the GtkBuildable interface supports a
custom `<attributes>` element, which supports any number of `<attribute>` custom `<attributes>` element, which supports any number of `<attribute>`
elements. The <attribute> element has attributes named “name“, “value“, elements. The `<attribute>` element has attributes named “name“, “value“,
“start“ and “end“ and allows you to specify [struct@Pango.Attribute] “start“ and “end“ and allows you to specify [struct@Pango.Attribute]
values for this label. values for this label.
@ -64,8 +64,9 @@ to the functions [ctor@Gtk.Label.new_with_mnemonic] or
Mnemonics automatically activate any activatable widget the label is Mnemonics automatically activate any activatable widget the label is
inside, such as a [class@Gtk.Button]; if the label is not inside the inside, such as a [class@Gtk.Button]; if the label is not inside the
mnemonics target widget, you have to tell the label about the target mnemonics target widget, you have to tell the label about the target
using [class@Gtk.Label.set_mnemonic_widget]. Heres a simple example where using [method@Gtk.Label.set_mnemonic_widget].
the label is inside a button:
Heres a simple example where the label is inside a button:
```c ```c
// Pressing Alt+H will activate this button // Pressing Alt+H will activate this button

View File

@ -0,0 +1,24 @@
**STRUCT**
# `NavigationView.NavigationStack`
A stack controls a navigation view.
## Properties
### `action`
The action to run at the next view update, if any.
## Methods
### `init()`
Initialize a navigation stack.
### `pop()`
Remove the last item from the navigation view.
### `push(_:)`
Add a new item to the navigation view.
- Parameter component: The component's value.

View File

@ -0,0 +1,248 @@
**STRUCT**
# `NavigationView`
A page-based navigation container.
<picture><source srcset="navigation-view-dark.png" media="(prefers-color-scheme: dark)"><img src="navigation-view.png" alt="navigation-view"></picture>
`AdwNavigationView` presents one child at a time, similar to
[class@Gtk.Stack].
`AdwNavigationView` can only contain [class@NavigationPage] children.
It maintains a navigation stack that can be controlled with
[method@NavigationView.push] and [method@NavigationView.pop]. The whole
navigation stack can also be replaced using [method@NavigationView.replace].
`AdwNavigationView` allows to manage pages statically or dynamically.
Static pages can be added using the [method@NavigationView.add] method. The
`AdwNavigationView` will keep a reference to these pages, but they aren't
accessible to the user until [method@NavigationView.push] is called (except
for the first page, which is pushed automatically). Use the
[method@NavigationView.remove] method to remove them. This is useful for
applications that have a small number of unique pages and just need
navigation between them.
Dynamic pages are automatically destroyed once they are popped off the
navigation stack. To add a page like this, push it using the
[method@NavigationView.push] method without calling
[method@NavigationView.add] first.
## Tags
Static pages, as well as any pages in the navigation stack, can be accessed
by their [property@NavigationPage:tag]. For example,
[method@NavigationView.push_by_tag] can be used to push a static page that's
not in the navigation stack without having to keep a reference to it manually.
## Header Bar Integration
When used inside `AdwNavigationView`, [class@HeaderBar] will automatically
display a back button that can be used to go back to the previous page when
possible. The button also has a context menu, allowing to pop multiple pages
at once, potentially across multiple navigation views.
Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior
if it's unwanted.
`AdwHeaderBar` will also display the title of the `AdwNavigationPage` it's
placed into, so most applications shouldn't need to customize it at all.
## Shortcuts and Gestures
`AdwNavigationView` supports the following shortcuts for going to the
previous page:
- <kbd>Escape</kbd> (unless [property@NavigationView:pop-on-escape] is set to
`FALSE`)
- <kbd>Alt</kbd>+<kbd></kbd>
- Back mouse button
Additionally, it supports interactive gestures:
- One-finger swipe towards the right on touchscreens
- Scrolling towards the right on touchpads (usually two-finger swipe)
These gestures have transitions enabled regardless of the
[property@NavigationView:animate-transitions] value.
Applications can also enable shortcuts for pushing another page onto the
navigation stack via connecting to the [signal@NavigationView::get-next-page]
signal, in that case the following shortcuts are supported:
- <kbd>Alt</kbd>+<kbd></kbd>
- Forward mouse button
- Swipe/scrolling towards the left
For right-to-left locales, the gestures and shortcuts are reversed.
[property@NavigationPage:can-pop] can be used to disable them, along with the
header bar back buttons.
## Actions
`AdwNavigationView` defines actions for controlling the navigation stack.
actions for controlling the navigation stack:
- `navigation.push` takes a string parameter specifying the tag of the page to
push, and is equivalent to calling [method@NavigationView.push_by_tag].
- `navigation.pop` doesn't take any parameters and pops the current page from
the navigation stack, equivalent to calling [method@NavigationView.pop].
## `AdwNavigationView` as `GtkBuildable`
`AdwNavigationView` allows to add pages as children, equivalent to using the
[method@NavigationView.add] method.
Example of an `AdwNavigationView` UI definition:
```xml
<object class="AdwNavigationView"><child><object class="AdwNavigationPage"><property name="title" translatable="yes">Page 1</property><property name="child"><object class="AdwToolbarView"><child type="top"><object class="AdwHeaderBar"/></child><property name="content"><object class="GtkButton"><property name="label" translatable="yes">Open Page 2</property><property name="halign">center</property><property name="valign">center</property><property name="action-name">navigation.push</property><property name="action-target">'page-2'</property><style><class name="pill"/></style></object></property></object></property></object></child><child><object class="AdwNavigationPage"><property name="title" translatable="yes">Page 2</property><property name="tag">page-2</property><property name="child"><object class="AdwToolbarView"><child type="top"><object class="AdwHeaderBar"/></child><property name="content"><!-- ... --></property></object></property></object></child></object>
```
<picture><source srcset="navigation-view-example-dark.png" media="(prefers-color-scheme: dark)"><img src="navigation-view-example.png" alt="navigation-view-example"></picture>
## CSS nodes
`AdwNavigationView` has a single CSS node with the name `navigation-view`.
## Accessibility
`AdwNavigationView` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role.
## Properties
### `updateFunctions`
Additional update functions for type extensions.
### `appearFunctions`
Additional appear functions for type extensions.
### `animateTransitions`
Whether to animate page transitions.
Gesture-based transitions are always animated.
### `popOnEscape`
Whether pressing Escape pops the current page.
Applications using `AdwNavigationView` to implement a browser may want to
disable it.
### `getNextPage`
Emitted when a push shortcut or a gesture is triggered.
To support the push shortcuts and gestures, the application is expected to
return the page to push in the handler.
This signal can be emitted multiple times for the gestures, for example
when the gesture is cancelled by the user. As such, the application must
not make any irreversible changes in the handler, such as removing the page
from a forward stack.
Instead, it should be done in the [signal@NavigationView::pushed] handler.
### `popped`
Emitted after @page has been popped from the navigation stack.
See [method@NavigationView.pop].
When using [method@NavigationView.pop_to_page] or
[method@NavigationView.pop_to_tag], this signal is emitted for each of the
popped pages.
### `pushed`
Emitted after a page has been pushed to the navigation stack.
See [method@NavigationView.push].
### `replaced`
Emitted after the navigation stack has been replaced.
See [method@NavigationView.replace].
### `app`
The application.
### `window`
The window.
## Methods
### `init()`
Initialize `NavigationView`.
### `container(modifiers:)`
Get the widget's view storage.
- Parameter modifiers: The view modifiers.
- Returns: The view storage.
### `update(_:modifiers:updateProperties:)`
Update the widget's view storage.
- Parameters:
- storage: The view storage.
- modifiers: The view modifiers.
- updateProperties: Whether to update the view's properties.
### `animateTransitions(_:)`
Whether to animate page transitions.
Gesture-based transitions are always animated.
### `popOnEscape(_:)`
Whether pressing Escape pops the current page.
Applications using `AdwNavigationView` to implement a browser may want to
disable it.
### `getNextPage(_:)`
Emitted when a push shortcut or a gesture is triggered.
To support the push shortcuts and gestures, the application is expected to
return the page to push in the handler.
This signal can be emitted multiple times for the gestures, for example
when the gesture is cancelled by the user. As such, the application must
not make any irreversible changes in the handler, such as removing the page
from a forward stack.
Instead, it should be done in the [signal@NavigationView::pushed] handler.
### `popped(_:)`
Emitted after @page has been popped from the navigation stack.
See [method@NavigationView.pop].
When using [method@NavigationView.pop_to_page] or
[method@NavigationView.pop_to_tag], this signal is emitted for each of the
popped pages.
### `pushed(_:)`
Emitted after a page has been pushed to the navigation stack.
See [method@NavigationView.push].
### `replaced(_:)`
Emitted after the navigation stack has been replaced.
See [method@NavigationView.replace].

View File

@ -90,6 +90,10 @@ The accessible role cannot be changed once set.
The child widget. The child widget.
When setting this property, if the child widget does not implement
[iface@Gtk.Scrollable], the scrolled window will add the child to
a [class@Gtk.Viewport] and then set the viewport as the child.
### `hasFrame` ### `hasFrame`
Whether to draw a frame around the contents. Whether to draw a frame around the contents.
@ -224,6 +228,10 @@ The accessible role cannot be changed once set.
The child widget. The child widget.
When setting this property, if the child widget does not implement
[iface@Gtk.Scrollable], the scrolled window will add the child to
a [class@Gtk.Viewport] and then set the viewport as the child.
### `hasFrame(_:)` ### `hasFrame(_:)`
Whether to draw a frame around the contents. Whether to draw a frame around the contents.

View File

@ -0,0 +1,5 @@
**TYPEALIAS**
# `NavigationStack`
A stack controls a navigation view.

View File

@ -114,9 +114,7 @@ public struct State<Value>: StateProtocol {
/// Update all of the views. /// Update all of the views.
/// - Parameter force: Whether to force all views to update. /// - Parameter force: Whether to force all views to update.
public static func updateViews(force: Bool = false) { public static func updateViews(force: Bool = false) {
for handler in GTUIApp.updateHandlers { UpdateManager.updateViews(force: force)
handler(force)
}
} }
/// The directory used for storing user data. /// The directory used for storing user data.

View File

@ -0,0 +1,24 @@
//
// UpdateManager.swift
// Adwaita
//
// Created by david-swift on 17.02.23.
//
/// This type manages view updates.
enum UpdateManager {
/// The class storing the value.
static var blockUpdates = false
/// Update all of the views.
/// - Parameter force: Whether to force all views to update.
static func updateViews(force: Bool = false) {
if !blockUpdates {
for handler in GTUIApp.updateHandlers {
handler(force)
}
}
}
}

View File

@ -33,7 +33,7 @@ extension FlowBox {
return nil return nil
} }
if let selection { if let selection {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields[Self.selectionField] = selection storage.fields[Self.selectionField] = selection
storage.connectSignal(name: "selected_children_changed", id: Self.selectionField) { storage.connectSignal(name: "selected_children_changed", id: Self.selectionField) {
if let binding = storage.fields[Self.selectionField] as? Binding<Element.ID>, if let binding = storage.fields[Self.selectionField] as? Binding<Element.ID>,
@ -43,14 +43,14 @@ extension FlowBox {
} }
} }
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if selection.wrappedValue != id(storage, elements), if selection.wrappedValue != id(storage, elements),
let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt { let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt {
gtk_flow_box_select_child(storage.pointer, gtk_flow_box_get_child_at_index(storage.pointer, index)) gtk_flow_box_select_child(storage.pointer, gtk_flow_box_get_child_at_index(storage.pointer, index))
} }
} }
} else { } else {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
gtk_flow_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE) gtk_flow_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE)
} }
} }

View File

@ -32,12 +32,12 @@ extension ComboRow {
selection.wrappedValue = id selection.wrappedValue = id
} }
}) })
appearFunctions.append { storage in appearFunctions.append { storage, _ in
let list = gtk_string_list_new(nil) let list = gtk_string_list_new(nil)
storage.fields[Self.stringList] = list storage.fields[Self.stringList] = list
adw_combo_row_set_model(storage.pointer?.cast(), list) adw_combo_row_set_model(storage.pointer?.cast(), list)
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if let list = storage.fields[Self.stringList] as? OpaquePointer { if let list = storage.fields[Self.stringList] as? OpaquePointer {
let old = storage.fields[Self.values] as? [Element] ?? [] let old = storage.fields[Self.values] as? [Element] ?? []
old.identifiableTransform( old.identifiableTransform(

View File

@ -18,7 +18,7 @@ extension EntryRow {
public init(_ title: String, text: Binding<String>) { public init(_ title: String, text: Binding<String>) {
self.init() self.init()
self = self.title(title) self = self.title(title)
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields[Self.textField] = text storage.fields[Self.textField] = text
storage.notify(name: "text") { storage.notify(name: "text") {
if let binding = storage.fields[Self.textField] as? Binding<String> { if let binding = storage.fields[Self.textField] as? Binding<String> {
@ -26,7 +26,7 @@ extension EntryRow {
} }
} }
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) { if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) {
gtk_editable_set_text(storage.pointer, text.wrappedValue) gtk_editable_set_text(storage.pointer, text.wrappedValue)
} }

View File

@ -18,7 +18,7 @@ extension PasswordEntryRow {
public init(_ title: String, text: Binding<String>) { public init(_ title: String, text: Binding<String>) {
self.init() self.init()
self = self.title(title) self = self.title(title)
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields[Self.textField] = text storage.fields[Self.textField] = text
storage.notify(name: "text") { storage.notify(name: "text") {
if let binding = storage.fields[Self.textField] as? Binding<String> { if let binding = storage.fields[Self.textField] as? Binding<String> {
@ -26,7 +26,7 @@ extension PasswordEntryRow {
} }
} }
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) { if text.wrappedValue != .init(cString: gtk_editable_get_text(storage.pointer)) {
gtk_editable_set_text(storage.pointer, text.wrappedValue) gtk_editable_set_text(storage.pointer, text.wrappedValue)
} }

View File

@ -35,7 +35,7 @@ extension SpinRow {
self = self.title(title) self = self.title(title)
self = self.value(value) self = self.value(value)
self = self.step(1) self = self.step(1)
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
adw_spin_row_set_range(storage.pointer, min, max) adw_spin_row_set_range(storage.pointer, min, max)
} }
} }
@ -52,7 +52,7 @@ extension SpinRow {
/// - Returns: The spin row. /// - Returns: The spin row.
public func step(_ step: Double) -> Self { public func step(_ step: Double) -> Self {
var newSelf = self var newSelf = self
newSelf.updateFunctions.append { storage in newSelf.updateFunctions.append { storage, _, _ in
let adjustment = adw_spin_row_get_adjustment(storage.pointer) let adjustment = adw_spin_row_get_adjustment(storage.pointer)
gtk_adjustment_set_step_increment(adjustment, step) gtk_adjustment_set_step_increment(adjustment, step)
} }

View File

@ -2,7 +2,7 @@
// ActionRow.swift // ActionRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -42,9 +42,9 @@ import LevenshteinTransformations
public struct ActionRow: Widget { public struct ActionRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The widget to activate when the row is activated. /// The widget to activate when the row is activated.
/// ///
@ -132,7 +132,7 @@ public struct ActionRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -206,7 +206,7 @@ public struct ActionRow: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Avatar.swift // Avatar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -31,9 +31,9 @@ import LevenshteinTransformations
public struct Avatar: Widget { public struct Avatar: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The name of an icon to use as a fallback. /// The name of an icon to use as a fallback.
/// ///
@ -69,7 +69,7 @@ public struct Avatar: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -98,7 +98,7 @@ public struct Avatar: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Banner.swift // Banner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -30,9 +30,9 @@ import LevenshteinTransformations
public struct Banner: Widget { public struct Banner: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The label to show on the button. /// The label to show on the button.
/// ///
@ -73,7 +73,7 @@ public struct Banner: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -107,7 +107,7 @@ public struct Banner: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Bin.swift // Bin.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -20,9 +20,9 @@ import LevenshteinTransformations
public struct Bin: Widget { public struct Bin: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The child widget of the `AdwBin`. /// The child widget of the `AdwBin`.
var child: (() -> Body)? var child: (() -> Body)?
@ -47,7 +47,7 @@ public struct Bin: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -67,7 +67,7 @@ public struct Bin: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Box.swift // Box.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -45,9 +45,9 @@ import LevenshteinTransformations
public struct Box: Widget { public struct Box: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -93,7 +93,7 @@ public struct Box: Widget {
} }
storage.content["prepend"] = prependStorage storage.content["prepend"] = prependStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -141,7 +141,7 @@ public struct Box: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Button.swift // Button.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -41,9 +41,9 @@ import LevenshteinTransformations
public struct Button: Widget { public struct Button: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -101,7 +101,7 @@ public struct Button: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -149,7 +149,7 @@ public struct Button: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ButtonContent.swift // ButtonContent.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -46,9 +46,9 @@ import LevenshteinTransformations
public struct ButtonContent: Widget { public struct ButtonContent: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether the button can be smaller than the natural size of its contents. /// Whether the button can be smaller than the natural size of its contents.
/// ///
@ -85,7 +85,7 @@ public struct ButtonContent: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -114,7 +114,7 @@ public struct ButtonContent: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Carousel.swift // Carousel.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -24,9 +24,9 @@ import LevenshteinTransformations
public struct Carousel<Element>: Widget where Element: Identifiable { public struct Carousel<Element>: Widget where Element: Identifiable {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether to allow swiping for more than one page at a time. /// Whether to allow swiping for more than one page at a time.
/// ///
@ -82,7 +82,7 @@ public struct Carousel<Element>: Widget where Element: Identifiable {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -145,7 +145,7 @@ public struct Carousel<Element>: Widget where Element: Identifiable {
} }
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// CenterBox.swift // CenterBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -45,9 +45,9 @@ import LevenshteinTransformations
public struct CenterBox: Widget { public struct CenterBox: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -105,7 +105,7 @@ public struct CenterBox: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -134,7 +134,7 @@ public struct CenterBox: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// CheckButton.swift // CheckButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -68,9 +68,9 @@ import LevenshteinTransformations
public struct CheckButton: Widget { public struct CheckButton: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -130,7 +130,7 @@ public struct CheckButton: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -181,7 +181,7 @@ if let active, newValue != active.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Clamp.swift // Clamp.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -29,9 +29,9 @@ import LevenshteinTransformations
public struct Clamp: Widget { public struct Clamp: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The child widget of the `AdwClamp`. /// The child widget of the `AdwClamp`.
var child: (() -> Body)? var child: (() -> Body)?
@ -75,7 +75,7 @@ public struct Clamp: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -101,7 +101,7 @@ public struct Clamp: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ComboRow.swift // ComboRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -44,9 +44,9 @@ import LevenshteinTransformations
public struct ComboRow: Widget { public struct ComboRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The widget to activate when the row is activated. /// The widget to activate when the row is activated.
/// ///
@ -156,7 +156,7 @@ public struct ComboRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -223,7 +223,7 @@ if let selected, newValue != selected.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// EntryRow.swift // EntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -42,9 +42,9 @@ import LevenshteinTransformations
public struct EntryRow: Widget { public struct EntryRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether activating the embedded entry can activate the default widget. /// Whether activating the embedded entry can activate the default widget.
var activatesDefault: Bool? var activatesDefault: Bool?
@ -118,7 +118,7 @@ public struct EntryRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -188,7 +188,7 @@ public struct EntryRow: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ExpanderRow.swift // ExpanderRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -36,9 +36,9 @@ import LevenshteinTransformations
public struct ExpanderRow: Widget { public struct ExpanderRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether expansion is enabled. /// Whether expansion is enabled.
var enableExpansion: Binding<Bool>? var enableExpansion: Binding<Bool>?
@ -120,7 +120,7 @@ public struct ExpanderRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -215,7 +215,7 @@ if let expanded, newValue != expanded.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// FlowBox.swift // FlowBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -55,9 +55,9 @@ import LevenshteinTransformations
public struct FlowBox<Element>: Widget where Element: Identifiable { public struct FlowBox<Element>: Widget where Element: Identifiable {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// accept-unpaired-release /// accept-unpaired-release
var acceptUnpairedRelease: Bool? var acceptUnpairedRelease: Bool?
@ -157,7 +157,7 @@ public struct FlowBox<Element>: Widget where Element: Identifiable {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -250,7 +250,7 @@ public struct FlowBox<Element>: Widget where Element: Identifiable {
} }
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// HeaderBar.swift // HeaderBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -85,9 +85,9 @@ import LevenshteinTransformations
public struct HeaderBar: Widget { public struct HeaderBar: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The decoration layout for buttons. /// The decoration layout for buttons.
/// ///
@ -175,7 +175,7 @@ public struct HeaderBar: Widget {
} }
storage.content["end"] = endStorage storage.content["end"] = endStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -232,7 +232,7 @@ public struct HeaderBar: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Label.swift // Label.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -40,7 +40,7 @@ import LevenshteinTransformations
/// ///
/// The GtkLabel implementation of the GtkBuildable interface supports a /// The GtkLabel implementation of the GtkBuildable interface supports a
/// custom `<attributes>` element, which supports any number of `<attribute>` /// custom `<attributes>` element, which supports any number of `<attribute>`
/// elements. The <attribute> element has attributes named name, value, /// elements. The `<attribute>` element has attributes named name, value,
/// start and end and allows you to specify [struct@Pango.Attribute] /// start and end and allows you to specify [struct@Pango.Attribute]
/// values for this label. /// values for this label.
/// ///
@ -70,8 +70,9 @@ import LevenshteinTransformations
/// Mnemonics automatically activate any activatable widget the label is /// Mnemonics automatically activate any activatable widget the label is
/// inside, such as a [class@Gtk.Button]; if the label is not inside the /// inside, such as a [class@Gtk.Button]; if the label is not inside the
/// mnemonics target widget, you have to tell the label about the target /// mnemonics target widget, you have to tell the label about the target
/// using [class@Gtk.Label.set_mnemonic_widget]. Heres a simple example where /// using [method@Gtk.Label.set_mnemonic_widget].
/// the label is inside a button: ///
/// Heres a simple example where the label is inside a button:
/// ///
/// ```c /// ```c
/// // Pressing Alt+H will activate this button /// // Pressing Alt+H will activate this button
@ -185,9 +186,9 @@ import LevenshteinTransformations
public struct Label: Widget { public struct Label: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -288,7 +289,7 @@ public struct Label: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -346,7 +347,7 @@ public struct Label: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// LevelBar.swift // LevelBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -108,9 +108,9 @@ import LevenshteinTransformations
public struct LevelBar: Widget { public struct LevelBar: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -153,7 +153,7 @@ public struct LevelBar: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -187,7 +187,7 @@ public struct LevelBar: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// LinkButton.swift // LinkButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -37,9 +37,9 @@ import LevenshteinTransformations
public struct LinkButton: Widget { public struct LinkButton: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -104,7 +104,7 @@ public struct LinkButton: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -158,7 +158,7 @@ public struct LinkButton: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ListBox.swift // ListBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -64,9 +64,9 @@ import LevenshteinTransformations
public struct ListBox<Element>: Widget where Element: Identifiable { public struct ListBox<Element>: Widget where Element: Identifiable {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether to accept unpaired release events. /// Whether to accept unpaired release events.
var acceptUnpairedRelease: Bool? var acceptUnpairedRelease: Bool?
@ -134,7 +134,7 @@ public struct ListBox<Element>: Widget where Element: Identifiable {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -220,7 +220,7 @@ public struct ListBox<Element>: Widget where Element: Identifiable {
} }
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Menu.swift // Menu.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -72,9 +72,9 @@ import LevenshteinTransformations
public struct Menu: Widget { public struct Menu: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -139,7 +139,7 @@ public struct Menu: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -194,7 +194,7 @@ if let active, newValue != active.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -0,0 +1,298 @@
//
// NavigationView.swift
// Adwaita
//
// Created by auto-generation on 17.02.24.
//
import CAdw
import LevenshteinTransformations
/// A page-based navigation container.
///
/// <picture><source srcset="navigation-view-dark.png" media="(prefers-color-scheme: dark)"><img src="navigation-view.png" alt="navigation-view"></picture>
///
/// `AdwNavigationView` presents one child at a time, similar to
/// [class@Gtk.Stack].
///
/// `AdwNavigationView` can only contain [class@NavigationPage] children.
///
/// It maintains a navigation stack that can be controlled with
/// [method@NavigationView.push] and [method@NavigationView.pop]. The whole
/// navigation stack can also be replaced using [method@NavigationView.replace].
///
/// `AdwNavigationView` allows to manage pages statically or dynamically.
///
/// Static pages can be added using the [method@NavigationView.add] method. The
/// `AdwNavigationView` will keep a reference to these pages, but they aren't
/// accessible to the user until [method@NavigationView.push] is called (except
/// for the first page, which is pushed automatically). Use the
/// [method@NavigationView.remove] method to remove them. This is useful for
/// applications that have a small number of unique pages and just need
/// navigation between them.
///
/// Dynamic pages are automatically destroyed once they are popped off the
/// navigation stack. To add a page like this, push it using the
/// [method@NavigationView.push] method without calling
/// [method@NavigationView.add] first.
///
/// ## Tags
///
/// Static pages, as well as any pages in the navigation stack, can be accessed
/// by their [property@NavigationPage:tag]. For example,
/// [method@NavigationView.push_by_tag] can be used to push a static page that's
/// not in the navigation stack without having to keep a reference to it manually.
///
/// ## Header Bar Integration
///
/// When used inside `AdwNavigationView`, [class@HeaderBar] will automatically
/// display a back button that can be used to go back to the previous page when
/// possible. The button also has a context menu, allowing to pop multiple pages
/// at once, potentially across multiple navigation views.
///
/// Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior
/// if it's unwanted.
///
/// `AdwHeaderBar` will also display the title of the `AdwNavigationPage` it's
/// placed into, so most applications shouldn't need to customize it at all.
///
/// ## Shortcuts and Gestures
///
/// `AdwNavigationView` supports the following shortcuts for going to the
/// previous page:
///
/// - <kbd>Escape</kbd> (unless [property@NavigationView:pop-on-escape] is set to
/// `FALSE`)
/// - <kbd>Alt</kbd>+<kbd></kbd>
/// - Back mouse button
///
/// Additionally, it supports interactive gestures:
///
/// - One-finger swipe towards the right on touchscreens
/// - Scrolling towards the right on touchpads (usually two-finger swipe)
///
/// These gestures have transitions enabled regardless of the
/// [property@NavigationView:animate-transitions] value.
///
/// Applications can also enable shortcuts for pushing another page onto the
/// navigation stack via connecting to the [signal@NavigationView::get-next-page]
/// signal, in that case the following shortcuts are supported:
///
/// - <kbd>Alt</kbd>+<kbd></kbd>
/// - Forward mouse button
/// - Swipe/scrolling towards the left
///
/// For right-to-left locales, the gestures and shortcuts are reversed.
///
/// [property@NavigationPage:can-pop] can be used to disable them, along with the
/// header bar back buttons.
///
/// ## Actions
///
/// `AdwNavigationView` defines actions for controlling the navigation stack.
/// actions for controlling the navigation stack:
///
/// - `navigation.push` takes a string parameter specifying the tag of the page to
/// push, and is equivalent to calling [method@NavigationView.push_by_tag].
///
/// - `navigation.pop` doesn't take any parameters and pops the current page from
/// the navigation stack, equivalent to calling [method@NavigationView.pop].
///
/// ## `AdwNavigationView` as `GtkBuildable`
///
/// `AdwNavigationView` allows to add pages as children, equivalent to using the
/// [method@NavigationView.add] method.
///
/// Example of an `AdwNavigationView` UI definition:
///
/// ```xml
/// <object class="AdwNavigationView"><child><object class="AdwNavigationPage"><property name="title" translatable="yes">Page 1</property><property name="child"><object class="AdwToolbarView"><child type="top"><object class="AdwHeaderBar"/></child><property name="content"><object class="GtkButton"><property name="label" translatable="yes">Open Page 2</property><property name="halign">center</property><property name="valign">center</property><property name="action-name">navigation.push</property><property name="action-target">'page-2'</property><style><class name="pill"/></style></object></property></object></property></object></child><child><object class="AdwNavigationPage"><property name="title" translatable="yes">Page 2</property><property name="tag">page-2</property><property name="child"><object class="AdwToolbarView"><child type="top"><object class="AdwHeaderBar"/></child><property name="content"><!-- ... --></property></object></property></object></child></object>
/// ```
///
/// <picture><source srcset="navigation-view-example-dark.png" media="(prefers-color-scheme: dark)"><img src="navigation-view-example.png" alt="navigation-view-example"></picture>
///
/// ## CSS nodes
///
/// `AdwNavigationView` has a single CSS node with the name `navigation-view`.
///
/// ## Accessibility
///
/// `AdwNavigationView` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role.
public struct NavigationView: Widget {
/// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether to animate page transitions.
///
/// Gesture-based transitions are always animated.
var animateTransitions: Bool?
/// Whether pressing Escape pops the current page.
///
/// Applications using `AdwNavigationView` to implement a browser may want to
/// disable it.
var popOnEscape: Bool?
/// Emitted when a push shortcut or a gesture is triggered.
///
/// To support the push shortcuts and gestures, the application is expected to
/// return the page to push in the handler.
///
/// This signal can be emitted multiple times for the gestures, for example
/// when the gesture is cancelled by the user. As such, the application must
/// not make any irreversible changes in the handler, such as removing the page
/// from a forward stack.
///
/// Instead, it should be done in the [signal@NavigationView::pushed] handler.
var getNextPage: (() -> Void)?
/// Emitted after @page has been popped from the navigation stack.
///
/// See [method@NavigationView.pop].
///
/// When using [method@NavigationView.pop_to_page] or
/// [method@NavigationView.pop_to_tag], this signal is emitted for each of the
/// popped pages.
var popped: (() -> Void)?
/// Emitted after a page has been pushed to the navigation stack.
///
/// See [method@NavigationView.push].
var pushed: (() -> Void)?
/// Emitted after the navigation stack has been replaced.
///
/// See [method@NavigationView.replace].
var replaced: (() -> Void)?
/// The application.
var app: GTUIApp?
/// The window.
var window: GTUIApplicationWindow?
/// Initialize `NavigationView`.
public init() {
}
/// Get the widget's view storage.
/// - Parameter modifiers: The view modifiers.
/// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {
let storage = ViewStorage(adw_navigation_view_new()?.opaque())
update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions {
function(storage, modifiers)
}
return storage
}
/// Update the widget's view storage.
/// - Parameters:
/// - storage: The view storage.
/// - modifiers: The view modifiers.
/// - updateProperties: Whether to update the view's properties.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
if let getNextPage {
storage.connectSignal(name: "get-next-page", argCount: 0) {
getNextPage()
}
}
if let popped {
storage.connectSignal(name: "popped", argCount: 1) {
popped()
}
}
if let pushed {
storage.connectSignal(name: "pushed", argCount: 0) {
pushed()
}
}
if let replaced {
storage.connectSignal(name: "replaced", argCount: 0) {
replaced()
}
}
storage.modify { widget in
if let animateTransitions, updateProperties {
adw_navigation_view_set_animate_transitions(widget, animateTransitions.cBool)
}
if let popOnEscape, updateProperties {
adw_navigation_view_set_pop_on_escape(widget, popOnEscape.cBool)
}
}
for function in updateFunctions {
function(storage, modifiers, updateProperties)
}
}
/// Whether to animate page transitions.
///
/// Gesture-based transitions are always animated.
public func animateTransitions(_ animateTransitions: Bool? = true) -> Self {
var newSelf = self
newSelf.animateTransitions = animateTransitions
return newSelf
}
/// Whether pressing Escape pops the current page.
///
/// Applications using `AdwNavigationView` to implement a browser may want to
/// disable it.
public func popOnEscape(_ popOnEscape: Bool? = true) -> Self {
var newSelf = self
newSelf.popOnEscape = popOnEscape
return newSelf
}
/// Emitted when a push shortcut or a gesture is triggered.
///
/// To support the push shortcuts and gestures, the application is expected to
/// return the page to push in the handler.
///
/// This signal can be emitted multiple times for the gestures, for example
/// when the gesture is cancelled by the user. As such, the application must
/// not make any irreversible changes in the handler, such as removing the page
/// from a forward stack.
///
/// Instead, it should be done in the [signal@NavigationView::pushed] handler.
public func getNextPage(_ getNextPage: @escaping () -> Void) -> Self {
var newSelf = self
newSelf.getNextPage = getNextPage
return newSelf
}
/// Emitted after @page has been popped from the navigation stack.
///
/// See [method@NavigationView.pop].
///
/// When using [method@NavigationView.pop_to_page] or
/// [method@NavigationView.pop_to_tag], this signal is emitted for each of the
/// popped pages.
public func popped(_ popped: @escaping () -> Void) -> Self {
var newSelf = self
newSelf.popped = popped
return newSelf
}
/// Emitted after a page has been pushed to the navigation stack.
///
/// See [method@NavigationView.push].
public func pushed(_ pushed: @escaping () -> Void) -> Self {
var newSelf = self
newSelf.pushed = pushed
return newSelf
}
/// Emitted after the navigation stack has been replaced.
///
/// See [method@NavigationView.replace].
public func replaced(_ replaced: @escaping () -> Void) -> Self {
var newSelf = self
newSelf.replaced = replaced
return newSelf
}
}

View File

@ -2,7 +2,7 @@
// Overlay.swift // Overlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -43,9 +43,9 @@ import LevenshteinTransformations
public struct Overlay: Widget { public struct Overlay: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -97,7 +97,7 @@ public struct Overlay: Widget {
} }
storage.content["overlay"] = overlayStorage storage.content["overlay"] = overlayStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -133,7 +133,7 @@ public struct Overlay: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// OverlaySplitView.swift // OverlaySplitView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -116,9 +116,9 @@ import LevenshteinTransformations
public struct OverlaySplitView: Widget { public struct OverlaySplitView: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether the split view is collapsed. /// Whether the split view is collapsed.
/// ///
@ -195,7 +195,7 @@ public struct OverlaySplitView: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -248,7 +248,7 @@ if let showSidebar, newValue != showSidebar.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// PasswordEntryRow.swift // PasswordEntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -27,9 +27,9 @@ import LevenshteinTransformations
public struct PasswordEntryRow: Widget { public struct PasswordEntryRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether activating the embedded entry can activate the default widget. /// Whether activating the embedded entry can activate the default widget.
var activatesDefault: Bool? var activatesDefault: Bool?
@ -103,7 +103,7 @@ public struct PasswordEntryRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -151,7 +151,7 @@ public struct PasswordEntryRow: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Popover.swift // Popover.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -71,9 +71,9 @@ import LevenshteinTransformations
public struct Popover: Widget { public struct Popover: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -124,7 +124,7 @@ public struct Popover: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -169,7 +169,7 @@ public struct Popover: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// PreferencesGroup.swift // PreferencesGroup.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -39,9 +39,9 @@ import LevenshteinTransformations
public struct PreferencesGroup: Widget { public struct PreferencesGroup: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The description for this group of preferences. /// The description for this group of preferences.
var description: String? var description: String?
@ -83,7 +83,7 @@ public struct PreferencesGroup: Widget {
} }
storage.content["child"] = childStorage storage.content["child"] = childStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -120,7 +120,7 @@ public struct PreferencesGroup: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// PreferencesPage.swift // PreferencesPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -25,9 +25,9 @@ import LevenshteinTransformations
public struct PreferencesPage: Widget { public struct PreferencesPage: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The description to be displayed at the top of the page. /// The description to be displayed at the top of the page.
var description: String? var description: String?
@ -64,7 +64,7 @@ public struct PreferencesPage: Widget {
} }
storage.content["child"] = childStorage storage.content["child"] = childStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -107,7 +107,7 @@ public struct PreferencesPage: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// PreferencesRow.swift // PreferencesRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -20,9 +20,9 @@ import LevenshteinTransformations
public struct PreferencesRow: Widget { public struct PreferencesRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The title of the preference represented by this row. /// The title of the preference represented by this row.
/// ///
@ -58,7 +58,7 @@ public struct PreferencesRow: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -87,7 +87,7 @@ public struct PreferencesRow: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ProgressBar.swift // ProgressBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -57,9 +57,9 @@ import LevenshteinTransformations
public struct ProgressBar: Widget { public struct ProgressBar: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -101,7 +101,7 @@ public struct ProgressBar: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -133,7 +133,7 @@ public struct ProgressBar: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ScrolledWindow.swift // ScrolledWindow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -79,15 +79,19 @@ import LevenshteinTransformations
public struct ScrolledWindow: Widget { public struct ScrolledWindow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
/// The accessible role cannot be changed once set. /// The accessible role cannot be changed once set.
var accessibleRole: String? var accessibleRole: String?
/// The child widget. /// The child widget.
///
/// When setting this property, if the child widget does not implement
/// [iface@Gtk.Scrollable], the scrolled window will add the child to
/// a [class@Gtk.Viewport] and then set the viewport as the child.
var child: (() -> Body)? var child: (() -> Body)?
/// Whether to draw a frame around the contents. /// Whether to draw a frame around the contents.
var hasFrame: Bool? var hasFrame: Bool?
@ -181,7 +185,7 @@ public struct ScrolledWindow: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -248,7 +252,7 @@ public struct ScrolledWindow: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }
@ -263,6 +267,10 @@ public struct ScrolledWindow: Widget {
} }
/// The child widget. /// The child widget.
///
/// When setting this property, if the child widget does not implement
/// [iface@Gtk.Scrollable], the scrolled window will add the child to
/// a [class@Gtk.Viewport] and then set the viewport as the child.
public func child(@ViewBuilder _ child: @escaping (() -> Body)) -> Self { public func child(@ViewBuilder _ child: @escaping (() -> Body)) -> Self {
var newSelf = self var newSelf = self
newSelf.child = child newSelf.child = child

View File

@ -2,7 +2,7 @@
// SearchBar.swift // SearchBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -55,9 +55,9 @@ import LevenshteinTransformations
public struct SearchBar: Widget { public struct SearchBar: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -96,7 +96,7 @@ public struct SearchBar: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -122,7 +122,7 @@ public struct SearchBar: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// SearchEntry.swift // SearchEntry.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -55,9 +55,9 @@ import LevenshteinTransformations
public struct SearchEntry: Widget { public struct SearchEntry: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -171,7 +171,7 @@ public struct SearchEntry: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -260,7 +260,7 @@ if let text, newValue != text.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// SpinRow.swift // SpinRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -27,9 +27,9 @@ import LevenshteinTransformations
public struct SpinRow: Widget { public struct SpinRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The widget to activate when the row is activated. /// The widget to activate when the row is activated.
/// ///
@ -148,7 +148,7 @@ public struct SpinRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -239,7 +239,7 @@ if let value, newValue != value.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// Spinner.swift // Spinner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -26,9 +26,9 @@ import LevenshteinTransformations
public struct Spinner: Widget { public struct Spinner: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -53,7 +53,7 @@ public struct Spinner: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -73,7 +73,7 @@ public struct Spinner: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// SplitButton.swift // SplitButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -43,9 +43,9 @@ import LevenshteinTransformations
public struct SplitButton: Widget { public struct SplitButton: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// Whether the button can be smaller than the natural size of its contents. /// Whether the button can be smaller than the natural size of its contents.
/// ///
@ -123,7 +123,7 @@ public struct SplitButton: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -168,7 +168,7 @@ public struct SplitButton: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// StatusPage.swift // StatusPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -25,9 +25,9 @@ import LevenshteinTransformations
public struct StatusPage: Widget { public struct StatusPage: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The child widget. /// The child widget.
var child: (() -> Body)? var child: (() -> Body)?
@ -62,7 +62,7 @@ public struct StatusPage: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -91,7 +91,7 @@ public struct StatusPage: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// SwitchRow.swift // SwitchRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -31,9 +31,9 @@ import LevenshteinTransformations
public struct SwitchRow: Widget { public struct SwitchRow: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The widget to activate when the row is activated. /// The widget to activate when the row is activated.
/// ///
@ -123,7 +123,7 @@ public struct SwitchRow: Widget {
} }
storage.content["prefix"] = prefixStorage storage.content["prefix"] = prefixStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -184,7 +184,7 @@ if let active, newValue != active.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ToastOverlay.swift // ToastOverlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -47,9 +47,9 @@ import LevenshteinTransformations
public struct ToastOverlay: Widget { public struct ToastOverlay: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The child widget. /// The child widget.
var child: (() -> Body)? var child: (() -> Body)?
@ -74,7 +74,7 @@ public struct ToastOverlay: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -94,7 +94,7 @@ public struct ToastOverlay: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ToggleButton.swift // ToggleButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -86,9 +86,9 @@ import LevenshteinTransformations
public struct ToggleButton: Widget { public struct ToggleButton: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation. /// The accessible role of the given `GtkAccessible` implementation.
/// ///
@ -150,7 +150,7 @@ public struct ToggleButton: Widget {
} }
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -212,7 +212,7 @@ if let active, newValue != active.wrappedValue {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// ToolbarView.swift // ToolbarView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -79,9 +79,9 @@ import LevenshteinTransformations
public struct ToolbarView: Widget { public struct ToolbarView: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The current bottom bar height. /// The current bottom bar height.
/// ///
@ -171,7 +171,7 @@ public struct ToolbarView: Widget {
} }
storage.content["top"] = topStorage storage.content["top"] = topStorage
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -225,7 +225,7 @@ public struct ToolbarView: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -2,7 +2,7 @@
// WindowTitle.swift // WindowTitle.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 14.02.24. // Created by auto-generation on 17.02.24.
// //
import CAdw import CAdw
@ -21,9 +21,9 @@ import LevenshteinTransformations
public struct WindowTitle: Widget { public struct WindowTitle: Widget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
/// The subtitle to display. /// The subtitle to display.
/// ///
@ -53,7 +53,7 @@ public struct WindowTitle: Widget {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -76,7 +76,7 @@ public struct WindowTitle: Widget {
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }

View File

@ -35,7 +35,7 @@ extension List {
return nil return nil
} }
if let selection { if let selection {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields[Self.selectionField] = selection storage.fields[Self.selectionField] = selection
storage.connectSignal(name: "selected_rows_changed", id: Self.selectionField) { storage.connectSignal(name: "selected_rows_changed", id: Self.selectionField) {
if let binding = storage.fields[Self.selectionField] as? Binding<Element.ID>, if let binding = storage.fields[Self.selectionField] as? Binding<Element.ID>,
@ -45,14 +45,14 @@ extension List {
} }
} }
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if selection.wrappedValue != id(storage, elements), if selection.wrappedValue != id(storage, elements),
let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt { let index = elements.firstIndex(where: { $0.id == selection.wrappedValue })?.cInt {
gtk_list_box_select_row(storage.pointer, gtk_list_box_get_row_at_index(storage.pointer, index)) gtk_list_box_select_row(storage.pointer, gtk_list_box_get_row_at_index(storage.pointer, index))
} }
} }
} else { } else {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
gtk_list_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE) gtk_list_box_set_selection_mode(storage.pointer, GTK_SELECTION_NONE)
} }
} }

View File

@ -14,7 +14,7 @@ extension Clamp {
init(vertical: Bool) { init(vertical: Bool) {
self.init() self.init()
if vertical { if vertical {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_VERTICAL) gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_VERTICAL)
} }
} }

View File

@ -13,7 +13,7 @@ extension Popover {
/// - Parameter vertical: Whether it is a vertical clamp. /// - Parameter vertical: Whether it is a vertical clamp.
init(visible: Binding<Bool>) { init(visible: Binding<Bool>) {
self.init() self.init()
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields["visible"] = visible storage.fields["visible"] = visible
storage.connectSignal(name: "closed", id: "visible") { storage.connectSignal(name: "closed", id: "visible") {
if let binding = storage.fields["visible"] as? Binding<Bool> { if let binding = storage.fields["visible"] as? Binding<Bool> {
@ -23,7 +23,7 @@ extension Popover {
} }
} }
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if let binding = storage.fields["visible"] as? Binding<Bool> { if let binding = storage.fields["visible"] as? Binding<Bool> {
if binding.wrappedValue { if binding.wrappedValue {
gtk_popover_popup(storage.pointer?.cast()) gtk_popover_popup(storage.pointer?.cast())

View File

@ -16,10 +16,10 @@ extension ToastOverlay {
/// - title: The toast's title. /// - title: The toast's title.
/// - signal: The signal for adding a toast. /// - signal: The signal for adding a toast.
public init(_ title: String, signal: Signal) { public init(_ title: String, signal: Signal) {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
storage.fields["signal"] = signal storage.fields["signal"] = signal
} }
updateFunctions.append { storage in updateFunctions.append { storage, _, _ in
if let signal = storage.fields["signal"] as? Signal, signal.update { if let signal = storage.fields["signal"] as? Signal, signal.update {
let toast = ViewStorage(adw_toast_new(title)) let toast = ViewStorage(adw_toast_new(title))
storage.fields[UUID().uuidString] = toast storage.fields[UUID().uuidString] = toast
@ -40,7 +40,7 @@ extension ToastOverlay {
/// - Returns: The toast overlay. /// - Returns: The toast overlay.
public func action(button: String, handler: @escaping () -> Void) -> Self { public func action(button: String, handler: @escaping () -> Void) -> Self {
var newSelf = self var newSelf = self
let action: (ViewStorage) -> Void = { storage in let action: (ViewStorage, [(View) -> View], Bool) -> Void = { storage, _, _ in
storage.fields["button"] = button storage.fields["button"] = button
storage.fields["handler"] = handler storage.fields["handler"] = handler
} }

View File

@ -0,0 +1,114 @@
//
// NavigationView+.swift
// Adwaita
//
// Created by david-swift on 17.02.24.
//
import CAdw
extension NavigationView {
/// The ID for the component field in a content storage.
static var componentID: String { "component" }
/// Initialize a navigation view.
/// - Parameters:
/// - stack: The navigation stack for pushing and popping.
/// - initialTitle: The title of the initial view.
/// - content: The view for a path component.
/// - initialView: The view that is displayed when the path is empty.
public init<Component>(
_ stack: Binding<NavigationStack<Component>>,
_ initialTitle: String,
@ViewBuilder content: @escaping (Component) -> Body,
@ViewBuilder initialView: @escaping () -> Body
) {
self.init()
appearFunctions.append { storage, modifiers in
let initialStorage = initialView().storage(modifiers: modifiers)
storage.fields[.mainContent] = [initialStorage]
adw_navigation_view_push(
storage.pointer,
adw_navigation_page_new(initialStorage.pointer?.cast(), initialTitle)
)
storage.connectSignal(name: "popped", id: "components", argCount: 1) { args in
guard var storages = storage.fields[.mainContent] as? [ViewStorage],
let arg = args.first as? UnsafeRawPointer else {
return
}
if storages.last?.pointer == adw_navigation_page_get_child(OpaquePointer(arg).cast())?.opaque() {
storages.removeLast()
storage.fields[.mainContent] = storages
}
}
}
updateFunctions.append { storage, modifiers, updateProperties in
guard var storages = storage.fields[.mainContent] as? [ViewStorage] else {
return
}
switch stack.wrappedValue.action {
case .pop:
if storages.count > 1 {
adw_navigation_view_pop(storage.pointer)
storages.removeLast()
} else { print("Warning: removing the initial view is not allowed.") }
case let .push(component):
let contentStorage = content(component).storage(modifiers: modifiers)
contentStorage.fields[Self.componentID] = component
storages.append(contentStorage)
adw_navigation_view_push(
storage.pointer,
adw_navigation_page_new(contentStorage.pointer?.cast(), component.description)
)
default:
break
}
UpdateManager.blockUpdates = true; stack.wrappedValue.action = nil; UpdateManager.blockUpdates = false
storage.fields[.mainContent] = storages
for storage in storages {
if let component = storage.fields[Self.componentID] as? Component {
content(component).updateStorage(storage, modifiers: modifiers, updateProperties: updateProperties)
} else {
initialView().updateStorage(storage, modifiers: modifiers, updateProperties: updateProperties)
}
}
}
}
/// A stack controls a navigation view.
public struct NavigationStack<Component> where Component: CustomStringConvertible {
/// The action to run at the next view update, if any.
var action: Action<Component>?
/// Initialize a navigation stack.
public init() { }
/// Remove the last item from the navigation view.
public mutating func pop() {
action = .pop
}
/// Add a new item to the navigation view.
/// - Parameter component: The component's value.
public mutating func push(_ component: Component) {
action = .push(component: component)
}
}
/// An action to run on a view update.
enum Action<Component> {
/// Remove the last item.
case pop
/// Add a new item.
case push(component: Component)
}
}
/// A stack controls a navigation view.
public typealias NavigationStack = NavigationView.NavigationStack

View File

@ -30,7 +30,7 @@ extension OverlaySplitView {
/// - Returns: The navigation split view. /// - Returns: The navigation split view.
public func trailingSidebar(_ trailing: Bool = true) -> Self { public func trailingSidebar(_ trailing: Bool = true) -> Self {
var newSelf = self var newSelf = self
newSelf.updateFunctions.append { storage in newSelf.updateFunctions.append { storage, _, _ in
adw_overlay_split_view_set_sidebar_position(storage.pointer, trailing ? GTK_PACK_END : GTK_PACK_START) adw_overlay_split_view_set_sidebar_position(storage.pointer, trailing ? GTK_PACK_END : GTK_PACK_START)
} }
return newSelf return newSelf

View File

@ -22,7 +22,7 @@ extension VStack {
self.init(spacing: 0) self.init(spacing: 0)
self = self.append(content) self = self.append(content)
if horizontal { if horizontal {
appearFunctions.append { storage in appearFunctions.append { storage, _ in
gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_HORIZONTAL) gtk_orientable_set_orientation(storage.pointer, GTK_ORIENTATION_HORIZONTAL)
} }
} }

View File

@ -84,9 +84,9 @@ struct Class: ClassLike, Decodable {
public struct \(definition) { public struct \(definition) {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
var updateFunctions: [(ViewStorage) -> Void] = [] var updateFunctions: [(ViewStorage, [(View) -> View], Bool) -> Void] = []
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage) -> Void] = [] var appearFunctions: [(ViewStorage, [(View) -> View]) -> Void] = []
\(generateProperties(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateProperties(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
/// Initialize `\(widgetName)`. /// Initialize `\(widgetName)`.
@ -100,7 +100,7 @@ struct Class: ClassLike, Decodable {
update(storage, modifiers: modifiers, updateProperties: true) update(storage, modifiers: modifiers, updateProperties: true)
\(generateWidgetAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateWidgetAssignments(config: config, genConfig: genConfig, namespace: namespace, configs: configs))
for function in appearFunctions { for function in appearFunctions {
function(storage) function(storage, modifiers)
} }
return storage return storage
} }
@ -117,7 +117,7 @@ struct Class: ClassLike, Decodable {
\(generateDynamicWidgetUpdate(config: config, genConfig: genConfig)) \(generateDynamicWidgetUpdate(config: config, genConfig: genConfig))
} }
for function in updateFunctions { for function in updateFunctions {
function(storage) function(storage, modifiers, updateProperties)
} }
} }
\(generateModifiers(config: config, genConfig: genConfig, namespace: namespace, configs: configs)) \(generateModifiers(config: config, genConfig: genConfig, namespace: namespace, configs: configs))

View File

@ -140,6 +140,10 @@ struct GenerationConfiguration {
class: "SplitButton", class: "SplitButton",
excludeProperties: ["direction", "popover"], excludeProperties: ["direction", "popover"],
setConditions: ["label": "storage.content[\"child\"] == nil"] setConditions: ["label": "storage.content[\"child\"] == nil"]
),
.init(
class: "NavigationView",
excludeProperties: ["navigation-stack", "visible-page"]
) )
] ]

View File

@ -62,6 +62,11 @@ struct Demo: App {
.closeShortcut() .closeShortcut()
.defaultSize(width: 400, height: 250) .defaultSize(width: 400, height: 250)
.title("Form Demo") .title("Form Demo")
Window(id: "navigation", open: 0) { _ in
NavigationViewDemo.WindowContent()
}
.closeShortcut()
.title("Navigation View Demo")
} }
} }

View File

@ -0,0 +1,64 @@
//
// NavigationViewDemo.swift
// Adwaita
//
// Created by david-swift on 17.02.24.
//
// swiftlint:disable missing_docs
import Adwaita
struct NavigationViewDemo: View {
var app: GTUIApp
var view: Body {
VStack {
Button("View Demo") {
app.showWindow("navigation")
}
.style("suggested-action")
.frame(maxSize: 100)
.padding()
}
}
struct WindowContent: View {
@State private var stack = NavigationStack<Int>()
let spacing = 10
var view: Body {
NavigationView($stack, "Initial View") { component in
VStack {
Button("Add Next View") {
stack.push(component + 1)
}
Button("Pop View") {
stack.pop()
}
}
.spacing(spacing)
.padding()
.topToolbar {
HeaderBar.empty()
}
} initialView: {
VStack {
Button("Add First View") {
stack.push(1)
}
.padding()
}
.topToolbar {
HeaderBar.empty()
}
}
}
}
}
// swiftlint:enable missing_docs

View File

@ -25,6 +25,7 @@ enum Page: String, Identifiable, CaseIterable, Codable {
case form case form
case popover case popover
case flowBox case flowBox
case navigationView
var id: Self { var id: Self {
self self
@ -38,6 +39,8 @@ enum Page: String, Identifiable, CaseIterable, Codable {
return "View Switcher" return "View Switcher"
case .flowBox: case .flowBox:
return "Flow Box" return "Flow Box"
case .navigationView:
return "Navigation View"
default: default:
return rawValue.capitalized return rawValue.capitalized
} }
@ -82,6 +85,8 @@ enum Page: String, Identifiable, CaseIterable, Codable {
return "Present content in a bubble-like context popup." return "Present content in a bubble-like context popup."
case .flowBox: case .flowBox:
return "Display views in a reflowing grid." return "Display views in a reflowing grid."
case .navigationView:
return "A page-based navigation container."
} }
} }
@ -117,6 +122,8 @@ enum Page: String, Identifiable, CaseIterable, Codable {
PopoverDemo() PopoverDemo()
case .flowBox: case .flowBox:
FlowBoxDemo() FlowBoxDemo()
case .navigationView:
NavigationViewDemo(app: app)
} }
} }
// swiftlint:enable cyclomatic_complexity // swiftlint:enable cyclomatic_complexity