portico/Sources/Portico/Generated/TabView.swift

586 lines
31 KiB
Swift

// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
import Adw
import Gtk
import Gio
import Gdk
// PorticoGen: generateStruct | source: Adw.TabView
/// A dynamic tabbed container.
///
/// `AdwTabView` is a container which shows one child at a time. While it
/// provides keyboard shortcuts for switching between pages, it does not provide
/// a visible tab switcher and relies on external widgets for that, such as
/// [class`TabBar`], [class`TabOverview`] and [class`TabButton`].
///
/// `AdwTabView` maintains a [class`TabPage`] object for each page, which holds
/// additional per-page properties. You can obtain the `AdwTabPage` for a page
/// with [method`TabView`.get_page], and as the return value for
/// [method`TabView`.append] and other functions for adding children.
///
/// `AdwTabView` only aims to be useful for dynamic tabs in multi-window
/// document-based applications, such as web browsers, file managers, text
/// editors or terminals. It does not aim to replace [class`Gtk`.Notebook] for use
/// cases such as tabbed dialogs.
///
/// As such, it does not support disabling page reordering or detaching.
///
/// `AdwTabView` adds a number of global page switching and reordering shortcuts.
/// The [property`TabView`:shortcuts] property can be used to manage them.
///
/// See [flags`TabViewShortcuts`] for the list of the available shortcuts. All of
/// the shortcuts are enabled by default.
///
/// [method`TabView`.add_shortcuts] and [method`TabView`.remove_shortcuts] can be
/// used to manage shortcuts in a convenient way, for example:
///
/// ```c
/// adw_tab_view_remove_shortcuts (view, ADW_TAB_VIEW_SHORTCUT_CONTROL_HOME |
/// ADW_TAB_VIEW_SHORTCUT_CONTROL_END);
/// ```
///
/// ## CSS nodes
///
/// `AdwTabView` has a main CSS node with the name `tabview`.
///
/// ## Accessibility
///
/// `AdwTabView` uses the [enum`Gtk`.AccessibleRole.tab-panel] role for the tab
/// pages which are the accessible parent objects of the child widgets.
///
/// A Portico view that mounts a `Adw.TabView`.
@MainActor public struct TabView: View {
private let make: (MountContext) -> Adw.TabView
private var configure: [(Adw.TabView, MountContext) -> Void] = []
public var body: Never { fatalError() }
// PorticoGen: generateInits(static) | source: Adw.TabView.init()
/// Creates a new `AdwTabView`.
///
/// Applied once at mount; use the `Binding` or closure overload for values that change.
/// Each closure is evaluated once; children are added in order and slot closures mount their first view.
/// An empty closure adds no children and leaves slots unset.
/// A `ForEach` in the `children:` closure spreads its rows directly into this widget, with no wrapper, when the widget supports ordered insertion.
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
///
/// - Parameter defaultIcon: Default page icon.
/// - Parameter menuModel: Tab context menu model.
/// - Parameter selectedPage: The currently selected page.
/// - Parameter shortcuts: The enabled shortcuts.
/// - Parameter children: A `ViewBuilder` closure whose views are added in order.
/// - Parameter onClosePage: Invoked when the widget emits the `close-page` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onCreateWindow: Invoked when the widget emits the `create-window` signal. Its return value is forwarded to GTK as the signal's result.
/// - Parameter onIndicatorActivated: Invoked when the widget emits the `indicator-activated` signal. The closure receives the signal's arguments in order.
/// - Parameter onPageAttached: Invoked when the widget emits the `page-attached` signal. The closure receives the signal's arguments in order.
/// - Parameter onPageDetached: Invoked when the widget emits the `page-detached` signal. The closure receives the signal's arguments in order.
/// - Parameter onPageReordered: Invoked when the widget emits the `page-reordered` signal. The closure receives the signal's arguments in order.
/// - Parameter onSetupMenu: Invoked when the widget emits the `setup-menu` signal. The closure receives the signal's arguments in order.
public init(defaultIcon: Adw.Icon? = nil, menuModel: Adw.MenuModel? = nil, selectedPage: Adw.TabPage? = nil, shortcuts: Adw.TabViewShortcuts? = nil, @ViewBuilder children: @escaping () -> [AnyView] = { [] }, onClosePage: ((Adw.TabPage) -> Bool)? = nil, onCreateWindow: (() -> Adw.TabView?)? = nil, onIndicatorActivated: ((Adw.TabPage) -> Void)? = nil, onPageAttached: ((Adw.TabPage, Int32) -> Void)? = nil, onPageDetached: ((Adw.TabPage, Int32) -> Void)? = nil, onPageReordered: ((Adw.TabPage, Int32) -> Void)? = nil, onSetupMenu: ((Adw.TabPage?) -> Void)? = nil) {
make = { _ in Adw.TabView() }
configure.append { w, ctx in
if let defaultIcon { w.setDefaultIcon(defaultIcon: defaultIcon) }
if let menuModel { w.setMenuModel(menuModel: menuModel) }
if let selectedPage { w.setSelectedPage(selectedPage: selectedPage) }
if let shortcuts { w.setShortcuts(shortcuts: shortcuts) }
Portico.mountChildren(children, into: w, ctx) { c in _ = w.append(child: c) }
if let onClosePage { ctx.registry.add(w.connectClosePage { _, a0 in onClosePage(a0) }) }
if let onCreateWindow { ctx.registry.add(w.connectCreateWindow { _ in onCreateWindow() }) }
if let onIndicatorActivated { ctx.registry.add(w.connectIndicatorActivated { _, a0 in onIndicatorActivated(a0) }) }
if let onPageAttached { ctx.registry.add(w.connectPageAttached { _, a0, a1 in onPageAttached(a0, a1) }) }
if let onPageDetached { ctx.registry.add(w.connectPageDetached { _, a0, a1 in onPageDetached(a0, a1) }) }
if let onPageReordered { ctx.registry.add(w.connectPageReordered { _, a0, a1 in onPageReordered(a0, a1) }) }
if let onSetupMenu { ctx.registry.add(w.connectSetupMenu { _, a0 in onSetupMenu(a0) }) }
}
}
}
extension TabView: WidgetView {
public typealias Target = Adw.TabView
@_spi(Portico) public func appending(
_ step: @escaping (Adw.TabView, MountContext) -> Void
) -> Self {
var c = self
c.configure.append(step)
return c
}
}
@_spi(Portico) extension TabView: Mountable {
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
let w = make(ctx)
for step in configure { step(w, ctx) }
return w
}
}
// PorticoGen: generateModifierExtension | source: Adw.TabView
/// Modifiers for `Adw.TabView`, available on every Portico view whose
/// backing widget is `Adw.TabView` or one of its subclasses.
extension WidgetView where Target: Adw.TabView {
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.TabView.append(child:)
/// Inserts `child` as the last non-pinned page.
///
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
///
/// - Parameter child: A child widget to add.
/// - Returns: A copy of this view with the modifier applied.
public func append(_ child: Gtk.Widget) -> Self {
appending { w, _ in
_ = w.append(child: child)
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.TabView.append(child:)
/// Inserts `child` as the last non-pinned page.
///
/// Every view the closure produces is added at mount, in order.
///
/// - Parameter child: A closure producing child views.
/// - Returns: A copy of this view with the modifier applied.
public func append(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
for v in childViews { _ = w.append(child: v.makeWidget(ctx)) }
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(static) | source: Adw.TabView.appendPinned(child:)
/// Inserts `child` as the last pinned page.
///
/// Applied once at mount; use the `@ViewBuilder` overload for multiple children.
///
/// - Parameter child: A child widget to add.
/// - Returns: A copy of this view with the modifier applied.
public func appendPinned(_ child: Gtk.Widget) -> Self {
appending { w, _ in
_ = w.appendPinned(child: child)
}
}
// PorticoGen: generateModifierExtension -> generateChildAdderModifiers(viewBuilder) | source: Adw.TabView.appendPinned(child:)
/// Inserts `child` as the last pinned page.
///
/// Every view the closure produces is added at mount, in order.
///
/// - Parameter child: A closure producing child views.
/// - Returns: A copy of this view with the modifier applied.
public func appendPinned(@ViewBuilder _ child: () -> [AnyView]) -> Self {
let childViews = child()
return appending { w, ctx in
for v in childViews { _ = w.appendPinned(child: v.makeWidget(ctx)) }
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabView.setDefaultIcon(defaultIcon:)
/// Sets the default page icon for `self`.
///
/// If a page doesn't provide its own icon via [property`TabPage`:icon], a default
/// icon may be used instead for contexts where having an icon is necessary.
///
/// [class`TabBar`] will use default icon for pinned tabs in case the page is not
/// loading, doesn't have an icon and an indicator. Default icon is never used
/// for tabs that aren't pinned.
///
/// [class`TabOverview`] will use default icon for pages with missing thumbnails.
///
/// By default, the `adw-tab-icon-missing-symbolic` icon is used.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter defaultIcon: Default page icon.
/// - Returns: A copy of this view with the modifier applied.
public func defaultIcon(_ defaultIcon: Adw.Icon) -> Self {
appending { w, _ in
w.setDefaultIcon(defaultIcon: defaultIcon)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabView.setDefaultIcon(defaultIcon:), GObject.Object.connectNotify(detail:_:), Adw.TabView.getDefaultIcon()
/// Sets the default page icon for `self`.
///
/// If a page doesn't provide its own icon via [property`TabPage`:icon], a default
/// icon may be used instead for contexts where having an icon is necessary.
///
/// [class`TabBar`] will use default icon for pinned tabs in case the page is not
/// loading, doesn't have an icon and an indicator. Default icon is never used
/// for tabs that aren't pinned.
///
/// [class`TabOverview`] will use default icon for pages with missing thumbnails.
///
/// By default, the `adw-tab-icon-missing-symbolic` icon is used.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.Icon` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func defaultIcon(_ defaultIcon: Portico.Binding<Adw.Icon>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, defaultIcon, registry: ctx.registry, notifyDetail: "default-icon",
read: { [w] in w.getDefaultIcon() },
write: { [w] v in w.setDefaultIcon(defaultIcon: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabView.setDefaultIcon(defaultIcon:)
/// Sets the default page icon for `self`.
///
/// If a page doesn't provide its own icon via [property`TabPage`:icon], a default
/// icon may be used instead for contexts where having an icon is necessary.
///
/// [class`TabBar`] will use default icon for pinned tabs in case the page is not
/// loading, doesn't have an icon and an indicator. Default icon is never used
/// for tabs that aren't pinned.
///
/// [class`TabOverview`] will use default icon for pages with missing thumbnails.
///
/// By default, the `adw-tab-icon-missing-symbolic` icon is used.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabView.setDefaultIcon(defaultIcon:)`.
///
/// - Parameter defaultIcon: Default page icon.
/// - Returns: A copy of this view with the modifier applied.
public func defaultIcon(_ defaultIcon: @escaping () -> Adw.Icon) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setDefaultIcon(defaultIcon: defaultIcon()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabView.setMenuModel(menuModel:)
/// Sets the tab context menu model for `self`.
///
/// When a context menu is shown for a tab, it will be constructed from the
/// provided menu model. Use the [signal`TabView`::setup-menu] signal to set up
/// the menu actions for the particular tab.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter menuModel: Tab context menu model.
/// - Returns: A copy of this view with the modifier applied.
public func menuModel(_ menuModel: Adw.MenuModel?) -> Self {
appending { w, _ in
w.setMenuModel(menuModel: menuModel)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabView.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Adw.TabView.getMenuModel()
/// Sets the tab context menu model for `self`.
///
/// When a context menu is shown for a tab, it will be constructed from the
/// provided menu model. Use the [signal`TabView`::setup-menu] signal to set up
/// the menu actions for the particular tab.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.MenuModel?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func menuModel(_ menuModel: Portico.Binding<Adw.MenuModel?>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, menuModel, registry: ctx.registry, notifyDetail: "menu-model",
read: { [w] in w.getMenuModel() },
write: { [w] v in w.setMenuModel(menuModel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Adw.TabView.setMenuModel(menuModel:), GObject.Object.connectNotify(detail:_:), Adw.TabView.getMenuModel()
/// Sets the tab context menu model for `self`.
///
/// When a context menu is shown for a tab, it will be constructed from the
/// provided menu model. Use the [signal`TabView`::setup-menu] signal to set up
/// the menu actions for the particular tab.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant, so a `Binding<Adw.MenuModel>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<Adw.MenuModel?>` to be able to clear the property.
/// When `Adw.MenuModel` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
/// A `nil` widget value is never written back into the binding.
///
/// - Returns: A copy of this view with the modifier applied.
public func menuModel(_ menuModel: Portico.Binding<Adw.MenuModel>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, menuModel, registry: ctx.registry, notifyDetail: "menu-model",
read: { [w] in w.getMenuModel() },
write: { [w] v in w.setMenuModel(menuModel: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabView.setMenuModel(menuModel:)
/// Sets the tab context menu model for `self`.
///
/// When a context menu is shown for a tab, it will be constructed from the
/// provided menu model. Use the [signal`TabView`::setup-menu] signal to set up
/// the menu actions for the particular tab.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabView.setMenuModel(menuModel:)`.
///
/// - Parameter menuModel: Tab context menu model.
/// - Returns: A copy of this view with the modifier applied.
public func menuModel(_ menuModel: @escaping () -> Adw.MenuModel?) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setMenuModel(menuModel: menuModel()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabView.setSelectedPage(selectedPage:)
/// Sets the currently selected page in `self`.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter selectedPage: The currently selected page.
/// - Returns: A copy of this view with the modifier applied.
public func selectedPage(_ selectedPage: Adw.TabPage) -> Self {
appending { w, _ in
w.setSelectedPage(selectedPage: selectedPage)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabView.setSelectedPage(selectedPage:), GObject.Object.connectNotify(detail:_:), Adw.TabView.getSelectedPage()
/// Sets the currently selected page in `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.TabPage` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func selectedPage(_ selectedPage: Portico.Binding<Adw.TabPage>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, selectedPage, registry: ctx.registry, notifyDetail: "selected-page",
read: { [w] in w.getSelectedPage() },
write: { [w] v in w.setSelectedPage(selectedPage: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lowered) | source: Adw.TabView.setSelectedPage(selectedPage:)
/// Sets the currently selected page in `self`.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// `Binding` is invariant and this property has no unset state; this overload accepts a nullable binding and ignores `nil` values. Binds one way only.
///
/// - Returns: A copy of this view with the modifier applied.
public func selectedPage(_ selectedPage: Portico.Binding<Adw.TabPage?>) -> Self {
appending { w, ctx in
if let v = selectedPage.untrackedValue { w.setSelectedPage(selectedPage: v) }
ctx.registry.add(selectedPage.subscribe { [w] v in if let v { w.setSelectedPage(selectedPage: v) } })
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabView.setSelectedPage(selectedPage:)
/// Sets the currently selected page in `self`.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabView.setSelectedPage(selectedPage:)`.
///
/// - Parameter selectedPage: The currently selected page.
/// - Returns: A copy of this view with the modifier applied.
public func selectedPage(_ selectedPage: @escaping () -> Adw.TabPage) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setSelectedPage(selectedPage: selectedPage()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Adw.TabView.setShortcuts(shortcuts:)
/// Sets the enabled shortcuts for `self`.
///
/// See [flags`TabViewShortcuts`] for the list of the available shortcuts. All of
/// the shortcuts are enabled by default.
///
/// [method`TabView`.add_shortcuts] and [method`TabView`.remove_shortcuts] provide
/// a convenient way to manage individual shortcuts.
///
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
///
/// - Parameter shortcuts: The enabled shortcuts.
/// - Returns: A copy of this view with the modifier applied.
public func shortcuts(_ shortcuts: Adw.TabViewShortcuts) -> Self {
appending { w, _ in
w.setShortcuts(shortcuts: shortcuts)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Adw.TabView.setShortcuts(shortcuts:), GObject.Object.connectNotify(detail:_:), Adw.TabView.getShortcuts()
/// Sets the enabled shortcuts for `self`.
///
/// See [flags`TabViewShortcuts`] for the list of the available shortcuts. All of
/// the shortcuts are enabled by default.
///
/// [method`TabView`.add_shortcuts] and [method`TabView`.remove_shortcuts] provide
/// a convenient way to manage individual shortcuts.
///
/// Applied at mount and re-applied on every change the binding publishes.
/// When `Adw.TabViewShortcuts` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
///
/// - Returns: A copy of this view with the modifier applied.
public func shortcuts(_ shortcuts: Portico.Binding<Adw.TabViewShortcuts>) -> Self {
appending { w, ctx in
Portico.bindProperty(
w, shortcuts, registry: ctx.registry, notifyDetail: "shortcuts",
read: { [w] in w.getShortcuts() },
write: { [w] v in w.setShortcuts(shortcuts: v) }
)
}
}
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Adw.TabView.setShortcuts(shortcuts:)
/// Sets the enabled shortcuts for `self`.
///
/// See [flags`TabViewShortcuts`] for the list of the available shortcuts. All of
/// the shortcuts are enabled by default.
///
/// [method`TabView`.add_shortcuts] and [method`TabView`.remove_shortcuts] provide
/// a convenient way to manage individual shortcuts.
///
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Adw.TabView.setShortcuts(shortcuts:)`.
///
/// - Parameter shortcuts: The enabled shortcuts.
/// - Returns: A copy of this view with the modifier applied.
public func shortcuts(_ shortcuts: @escaping () -> Adw.TabViewShortcuts) -> Self {
appending { w, ctx in
let tracker = DependencyTracker { [w] in w.setShortcuts(shortcuts: shortcuts()) }
tracker.run()
ctx.registry.add(tracker)
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectClosePage(_:)
/// Emitted after [method`TabView`.close_page] has been called for `page`.
///
/// The handler is expected to call [method`TabView`.close_page_finish] to
/// confirm or reject the closing.
///
/// The default handler will immediately confirm closing for non-pinned pages,
/// or reject it for pinned pages, equivalent to the following example:
///
/// ```c
/// static gboolean
/// close_page_cb (AdwTabView *view,
/// AdwTabPage *page,
/// gpointer user_data)
/// {
/// adw_tab_view_close_page_finish (view, page, !adw_tab_page_get_pinned (page));
///
/// return GDK_EVENT_STOP;
/// }
/// ```
///
/// The [method`TabView`.close_page_finish] call doesn't have to happen inside
/// the handler, so can be used to do asynchronous checks before confirming the
/// closing.
///
/// A typical reason to connect to this signal is to show a confirmation dialog
/// for closing a tab.
///
/// The signal handler should return [const`Gdk`.EVENT_STOP] to stop propagation
/// or [const`Gdk`.EVENT_PROPAGATE] to invoke the default handler.
///
/// - Parameter handler: Invoked when the widget emits the `close-page` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onClosePage(_ handler: @escaping (Adw.TabPage) -> Bool) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectClosePage { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectCreateWindow(_:)
/// Emitted when a tab should be transferred into a new window.
///
/// This can happen after a tab has been dropped on desktop.
///
/// The signal handler is expected to create a new window, position it as
/// needed and return its `AdwTabView` that the page will be transferred into.
///
/// - Parameter handler: Invoked when the widget emits the `create-window` signal. Its return value is forwarded to GTK as the signal's result.
/// - Returns: A copy of this view with the modifier applied.
public func onCreateWindow(_ handler: @escaping () -> Adw.TabView?) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectCreateWindow { _ in handler() })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectIndicatorActivated(_:)
/// Emitted after the indicator icon on `page` has been activated.
///
/// See [property`TabPage`:indicator-icon] and
/// [property`TabPage`:indicator-activatable].
///
/// - Parameter handler: Invoked when the widget emits the `indicator-activated` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onIndicatorActivated(_ handler: @escaping (Adw.TabPage) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectIndicatorActivated { _, a0 in handler(a0) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectPageAttached(_:)
/// Emitted when a page has been created or transferred to `self`.
///
/// A typical reason to connect to this signal would be to connect to page
/// signals for things such as updating window title.
///
/// - Parameter handler: Invoked when the widget emits the `page-attached` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onPageAttached(_ handler: @escaping (Adw.TabPage, Int32) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectPageAttached { _, a0, a1 in handler(a0, a1) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectPageDetached(_:)
/// Emitted when a page has been removed or transferred to another view.
///
/// A typical reason to connect to this signal would be to disconnect signal
/// handlers connected in the [signal`TabView`::page-attached] handler.
///
/// It is important not to try and destroy the page child in the handler of
/// this function as the child might merely be moved to another window; use
/// child dispose handler for that or do it in sync with your
/// [method`TabView`.close_page_finish] calls.
///
/// - Parameter handler: Invoked when the widget emits the `page-detached` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onPageDetached(_ handler: @escaping (Adw.TabPage, Int32) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectPageDetached { _, a0, a1 in handler(a0, a1) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectPageReordered(_:)
/// Emitted after `page` has been reordered to `position`.
///
/// - Parameter handler: Invoked when the widget emits the `page-reordered` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onPageReordered(_ handler: @escaping (Adw.TabPage, Int32) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectPageReordered { _, a0, a1 in handler(a0, a1) })
}
}
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Adw.TabView.connectSetupMenu(_:)
/// Emitted when a context menu is opened or closed for `page`.
///
/// If the menu has been closed, `page` will be set to `NULL`.
///
/// It can be used to set up menu actions before showing the menu, for example
/// disable actions not applicable to `page`.
///
/// - Parameter handler: Invoked when the widget emits the `setup-menu` signal. The closure receives the signal's arguments in order.
/// - Returns: A copy of this view with the modifier applied.
public func onSetupMenu(_ handler: @escaping (Adw.TabPage?) -> Void) -> Self {
appending { w, ctx in
ctx.registry.add(w.connectSetupMenu { _, a0 in handler(a0) })
}
}
}