692 lines
37 KiB
Swift
692 lines
37 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.Notebook
|
|
/// Switches between children using tabs.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="notebook-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkNotebook" src="notebook.png">
|
|
/// </picture>
|
|
///
|
|
/// There are many configuration options for `GtkNotebook`. Among
|
|
/// other things, you can choose on which edge the tabs appear
|
|
/// (see [method`Gtk`.Notebook.set_tab_pos]), whether, if there are
|
|
/// too many tabs to fit the notebook should be made bigger or scrolling
|
|
/// arrows added (see [method`Gtk`.Notebook.set_scrollable]), and whether
|
|
/// there will be a popup menu allowing the users to switch pages.
|
|
/// (see [method`Gtk`.Notebook.popup_enable]).
|
|
///
|
|
/// # GtkNotebook as GtkBuildable
|
|
///
|
|
/// The `GtkNotebook` implementation of the `GtkBuildable` interface
|
|
/// supports placing children into tabs by specifying “tab” as the
|
|
/// “type” attribute of a `<child>` element. Note that the content
|
|
/// of the tab must be created before the tab can be filled.
|
|
/// A tab child can be specified without specifying a `<child>`
|
|
/// type attribute.
|
|
///
|
|
/// To add a child widget in the notebooks action area, specify
|
|
/// "action-start" or “action-end” as the “type” attribute of the
|
|
/// `<child>` element.
|
|
///
|
|
/// An example of a UI definition fragment with `GtkNotebook`:
|
|
///
|
|
/// ```xml
|
|
/// <object class="GtkNotebook">
|
|
/// <child>
|
|
/// <object class="GtkLabel" id="notebook-content">
|
|
/// <property name="label">Content</property>
|
|
/// </object>
|
|
/// </child>
|
|
/// <child type="tab">
|
|
/// <object class="GtkLabel" id="notebook-tab">
|
|
/// <property name="label">Tab</property>
|
|
/// </object>
|
|
/// </child>
|
|
/// </object>
|
|
/// ```
|
|
///
|
|
/// # Shortcuts and Gestures
|
|
///
|
|
/// `GtkNotebook` supports the following keyboard shortcuts:
|
|
///
|
|
/// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
|
|
/// - <kbd>Home</kbd> moves the focus to the first tab.
|
|
/// - <kbd>End</kbd> moves the focus to the last tab.
|
|
///
|
|
/// Additionally, the following signals have default keybindings:
|
|
///
|
|
/// - [signal`Gtk`.Notebook::change-current-page]
|
|
/// - [signal`Gtk`.Notebook::focus-tab]
|
|
/// - [signal`Gtk`.Notebook::move-focus-out]
|
|
/// - [signal`Gtk`.Notebook::reorder-tab]
|
|
/// - [signal`Gtk`.Notebook::select-page]
|
|
///
|
|
/// Tabs support drag-and-drop between notebooks sharing the same `group-name`,
|
|
/// or to new windows by handling the `::create-window` signal.
|
|
///
|
|
/// # Actions
|
|
///
|
|
/// `GtkNotebook` defines a set of built-in actions:
|
|
///
|
|
/// - `menu.popup` opens the tabs context menu.
|
|
///
|
|
/// # CSS nodes
|
|
///
|
|
/// ```
|
|
/// notebook
|
|
/// ├── header.top
|
|
/// │ ├── [<action widget>]
|
|
/// │ ├── tabs
|
|
/// │ │ ├── [arrow]
|
|
/// │ │ ├── tab
|
|
/// │ │ │ ╰── <tab label>
|
|
/// ┊ ┊ ┊
|
|
/// │ │ ├── tab[.reorderable-page]
|
|
/// │ │ │ ╰── <tab label>
|
|
/// │ │ ╰── [arrow]
|
|
/// │ ╰── [<action widget>]
|
|
/// │
|
|
/// ╰── stack
|
|
/// ├── <child>
|
|
/// ┊
|
|
/// ╰── <child>
|
|
/// ```
|
|
///
|
|
/// `GtkNotebook` has a main CSS node with name `notebook`, a subnode
|
|
/// with name `header` and below that a subnode with name `tabs` which
|
|
/// contains one subnode per tab with name `tab`.
|
|
///
|
|
/// If action widgets are present, their CSS nodes are placed next
|
|
/// to the `tabs` node. If the notebook is scrollable, CSS nodes with
|
|
/// name `arrow` are placed as first and last child of the `tabs` node.
|
|
///
|
|
/// The main node gets the `.frame` style class when the notebook
|
|
/// has a border (see [method`Gtk`.Notebook.set_show_border]).
|
|
///
|
|
/// The header node gets one of the style class `.top`, `.bottom`,
|
|
/// `.left` or `.right`, depending on where the tabs are placed. For
|
|
/// reorderable pages, the tab node gets the `.reorderable-page` class.
|
|
///
|
|
/// A `tab` node gets the `.dnd` style class while it is moved with drag-and-drop.
|
|
///
|
|
/// The nodes are always arranged from left-to-right, regardless of text direction.
|
|
///
|
|
/// # Accessibility
|
|
///
|
|
/// `GtkNotebook` uses the following roles:
|
|
///
|
|
/// - [enum`Gtk`.AccessibleRole.group] for the notebook widget
|
|
/// - [enum`Gtk`.AccessibleRole.tab_list] for the list of tabs
|
|
/// - [enum`Gtk`.AccessibleRole.tab] role for each tab
|
|
/// - [enum`Gtk`.AccessibleRole.tab_panel] for each page
|
|
///
|
|
/// A Portico view that mounts a `Gtk.Notebook`.
|
|
@MainActor public struct Notebook: View {
|
|
private let make: (MountContext) -> Gtk.Notebook
|
|
private var configure: [(Gtk.Notebook, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.Notebook.init()
|
|
/// Creates a new `GtkNotebook` widget with no pages.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for values that change.
|
|
/// Optional value parameters are applied only when non-`nil`; a `nil` argument leaves the widget's own default in place and cannot clear a nullable property - use the matching modifier for that.
|
|
///
|
|
/// - Parameter groupName: Group name for tab drag and drop.
|
|
/// - Parameter page: The index of the current page.
|
|
/// - Parameter scrollable: If `true`, scroll arrows are added if there are too many pages to fit.
|
|
/// - Parameter showBorder: Whether the border should be shown.
|
|
/// - Parameter showTabs: Whether tabs should be shown.
|
|
/// - Parameter tabPos: Which side of the notebook holds the tabs.
|
|
/// - Parameter onChangeCurrentPage: Invoked when the widget emits the `change-current-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. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onFocusTab: Invoked when the widget emits the `focus-tab` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onMoveFocusOut: Invoked when the widget emits the `move-focus-out` signal. The closure receives the signal's arguments in order.
|
|
/// - Parameter onPageAdded: Invoked when the widget emits the `page-added` signal. The closure receives the signal's arguments in order.
|
|
/// - Parameter onPageRemoved: Invoked when the widget emits the `page-removed` 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 onReorderTab: Invoked when the widget emits the `reorder-tab` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onSelectPage: Invoked when the widget emits the `select-page` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onSwitchPage: Invoked when the widget emits the `switch-page` signal. The closure receives the signal's arguments in order.
|
|
public init(groupName: String? = nil, page: Int32? = nil, scrollable: Bool? = nil, showBorder: Bool? = nil, showTabs: Bool? = nil, tabPos: Gtk.PositionType? = nil, onChangeCurrentPage: ((Int32) -> Bool)? = nil, onCreateWindow: ((Gtk.Widget) -> Gtk.Notebook?)? = nil, onFocusTab: ((Gtk.NotebookTab) -> Bool)? = nil, onMoveFocusOut: ((Gtk.DirectionType) -> Void)? = nil, onPageAdded: ((Gtk.Widget, UInt32) -> Void)? = nil, onPageRemoved: ((Gtk.Widget, UInt32) -> Void)? = nil, onPageReordered: ((Gtk.Widget, UInt32) -> Void)? = nil, onReorderTab: ((Gtk.DirectionType, Bool) -> Bool)? = nil, onSelectPage: ((Bool) -> Bool)? = nil, onSwitchPage: ((Gtk.Widget, UInt32) -> Void)? = nil) {
|
|
make = { _ in Gtk.Notebook() }
|
|
configure.append { w, ctx in
|
|
if let groupName { w.setGroupName(groupName: groupName) }
|
|
if let page { w.setCurrentPage(pageNum: page) }
|
|
if let scrollable { w.setScrollable(scrollable: scrollable) }
|
|
if let showBorder { w.setShowBorder(showBorder: showBorder) }
|
|
if let showTabs { w.setShowTabs(showTabs: showTabs) }
|
|
if let tabPos { w.setTabPos(pos: tabPos) }
|
|
if let onChangeCurrentPage { ctx.registry.add(w.connectChangeCurrentPage { _, a0 in onChangeCurrentPage(a0) }) }
|
|
if let onCreateWindow { ctx.registry.add(w.connectCreateWindow { _, a0 in onCreateWindow(a0) }) }
|
|
if let onFocusTab { ctx.registry.add(w.connectFocusTab { _, a0 in onFocusTab(a0) }) }
|
|
if let onMoveFocusOut { ctx.registry.add(w.connectMoveFocusOut { _, a0 in onMoveFocusOut(a0) }) }
|
|
if let onPageAdded { ctx.registry.add(w.connectPageAdded { _, a0, a1 in onPageAdded(a0, a1) }) }
|
|
if let onPageRemoved { ctx.registry.add(w.connectPageRemoved { _, a0, a1 in onPageRemoved(a0, a1) }) }
|
|
if let onPageReordered { ctx.registry.add(w.connectPageReordered { _, a0, a1 in onPageReordered(a0, a1) }) }
|
|
if let onReorderTab { ctx.registry.add(w.connectReorderTab { _, a0, a1 in onReorderTab(a0, a1) }) }
|
|
if let onSelectPage { ctx.registry.add(w.connectSelectPage { _, a0 in onSelectPage(a0) }) }
|
|
if let onSwitchPage { ctx.registry.add(w.connectSwitchPage { _, a0, a1 in onSwitchPage(a0, a1) }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension Notebook: WidgetView {
|
|
public typealias Target = Gtk.Notebook
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.Notebook, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension Notebook: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension | source: Gtk.Notebook
|
|
/// Modifiers for `Gtk.Notebook`, available on every Portico view whose
|
|
/// backing widget is `Gtk.Notebook` or one of its subclasses.
|
|
extension WidgetView where Target: Gtk.Notebook {
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setGroupName(groupName:)
|
|
/// Sets a group name for `notebook`.
|
|
///
|
|
/// Notebooks with the same name will be able to exchange tabs
|
|
/// via drag and drop. A notebook with a `nil` group name will
|
|
/// not be able to exchange tabs with any other notebook.
|
|
///
|
|
/// Applied once at mount; use the `Binding`, closure, or `InterpolatedText` overload for a value that changes.
|
|
/// A string literal containing interpolation selects the `InterpolatedText` overload instead, which updates live.
|
|
///
|
|
/// - Parameter groupName: Group name for tab drag and drop.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
@_disfavoredOverload
|
|
public func groupName<S: StringProtocol>(_ groupName: S?) -> Self {
|
|
appending { w, _ in
|
|
w.setGroupName(groupName: groupName.map { String($0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setGroupName(groupName:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getGroupName()
|
|
/// Sets a group name for `notebook`.
|
|
///
|
|
/// Notebooks with the same name will be able to exchange tabs
|
|
/// via drag and drop. A notebook with a `nil` group name will
|
|
/// not be able to exchange tabs with any other notebook.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `String?` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func groupName(_ groupName: Portico.Binding<String?>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, groupName, registry: ctx.registry, notifyDetail: "group-name",
|
|
read: { [w] in w.getGroupName() },
|
|
write: { [w] v in w.setGroupName(groupName: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(lifted,twoWay) | source: Gtk.Notebook.setGroupName(groupName:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getGroupName()
|
|
/// Sets a group name for `notebook`.
|
|
///
|
|
/// Notebooks with the same name will be able to exchange tabs
|
|
/// via drag and drop. A notebook with a `nil` group name will
|
|
/// not be able to exchange tabs with any other notebook.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// `Binding` is invariant, so a `Binding<String>` is not accepted by the nullable overload; this one takes it and promotes each value. Pass a `Binding<String?>` to be able to clear the property.
|
|
/// When `String` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
/// A `nil` widget value is never written back into the binding.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func groupName(_ groupName: Portico.Binding<String>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, groupName, registry: ctx.registry, notifyDetail: "group-name",
|
|
read: { [w] in w.getGroupName() },
|
|
write: { [w] v in w.setGroupName(groupName: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setGroupName(groupName:)
|
|
/// Sets a group name for `notebook`.
|
|
///
|
|
/// Notebooks with the same name will be able to exchange tabs
|
|
/// via drag and drop. A notebook with a `nil` group name will
|
|
/// not be able to exchange tabs with any other notebook.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setGroupName(groupName:)`.
|
|
///
|
|
/// - Parameter groupName: Group name for tab drag and drop.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func groupName(_ groupName: @escaping () -> String?) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setGroupName(groupName: groupName()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(interpolation) | source: Gtk.Notebook.setGroupName(groupName:)
|
|
/// Sets a group name for `notebook`.
|
|
///
|
|
/// Notebooks with the same name will be able to exchange tabs
|
|
/// via drag and drop. A notebook with a `nil` group name will
|
|
/// not be able to exchange tabs with any other notebook.
|
|
///
|
|
/// Interpolated segments are captured unevaluated and re-read inside a `DependencyTracker`, so any `@State` they read pushes a new value through `Gtk.Notebook.setGroupName(groupName:)`. A literal with no interpolation is applied once, with no subscription.
|
|
///
|
|
/// - Parameter groupName: Group name for tab drag and drop.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func groupName(_ groupName: Portico.InterpolatedText?) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindOptionalInterpolation(groupName, registry: ctx.registry) { [w] v in w.setGroupName(groupName: v) }
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setCurrentPage(pageNum:)
|
|
/// Switches to the page number `page_num`.
|
|
///
|
|
/// Note that due to historical reasons, GtkNotebook refuses
|
|
/// to switch to a page unless the child widget is visible.
|
|
/// Therefore, it is recommended to show child widgets before
|
|
/// adding them to a notebook.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter page: The index of the current page.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func page(_ page: Int32) -> Self {
|
|
appending { w, _ in
|
|
w.setCurrentPage(pageNum: page)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setCurrentPage(pageNum:), GObject.Object.connectNotify(detail:_:)
|
|
/// Switches to the page number `page_num`.
|
|
///
|
|
/// Note that due to historical reasons, GtkNotebook refuses
|
|
/// to switch to a page unless the child widget is visible.
|
|
/// Therefore, it is recommended to show child widgets before
|
|
/// adding them to a notebook.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Int32` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func page(_ page: Portico.Binding<Int32>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, page, registry: ctx.registry, notifyDetail: "page",
|
|
read: { [w] in w.page },
|
|
write: { [w] v in w.setCurrentPage(pageNum: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setCurrentPage(pageNum:)
|
|
/// Switches to the page number `page_num`.
|
|
///
|
|
/// Note that due to historical reasons, GtkNotebook refuses
|
|
/// to switch to a page unless the child widget is visible.
|
|
/// Therefore, it is recommended to show child widgets before
|
|
/// adding them to a notebook.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setCurrentPage(pageNum:)`.
|
|
///
|
|
/// - Parameter page: The index of the current page.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func page(_ page: @escaping () -> Int32) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setCurrentPage(pageNum: page()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setScrollable(scrollable:)
|
|
/// Sets whether the tab label area will have arrows for
|
|
/// scrolling if there are too many tabs to fit in the area.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter scrollable: If `true`, scroll arrows are added if there are too many pages to fit.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func scrollable(_ scrollable: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setScrollable(scrollable: scrollable)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setScrollable(scrollable:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getScrollable()
|
|
/// Sets whether the tab label area will have arrows for
|
|
/// scrolling if there are too many tabs to fit in the area.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func scrollable(_ scrollable: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, scrollable, registry: ctx.registry, notifyDetail: "scrollable",
|
|
read: { [w] in w.getScrollable() },
|
|
write: { [w] v in w.setScrollable(scrollable: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setScrollable(scrollable:)
|
|
/// Sets whether the tab label area will have arrows for
|
|
/// scrolling if there are too many tabs to fit in the area.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setScrollable(scrollable:)`.
|
|
///
|
|
/// - Parameter scrollable: If `true`, scroll arrows are added if there are too many pages to fit.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func scrollable(_ scrollable: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setScrollable(scrollable: scrollable()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setShowBorder(showBorder:)
|
|
/// Sets whether a bevel will be drawn around the notebook pages.
|
|
///
|
|
/// This only has a visual effect when the tabs are not shown.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter showBorder: Whether the border should be shown.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showBorder(_ showBorder: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setShowBorder(showBorder: showBorder)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setShowBorder(showBorder:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getShowBorder()
|
|
/// Sets whether a bevel will be drawn around the notebook pages.
|
|
///
|
|
/// This only has a visual effect when the tabs are not shown.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showBorder(_ showBorder: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, showBorder, registry: ctx.registry, notifyDetail: "show-border",
|
|
read: { [w] in w.getShowBorder() },
|
|
write: { [w] v in w.setShowBorder(showBorder: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setShowBorder(showBorder:)
|
|
/// Sets whether a bevel will be drawn around the notebook pages.
|
|
///
|
|
/// This only has a visual effect when the tabs are not shown.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setShowBorder(showBorder:)`.
|
|
///
|
|
/// - Parameter showBorder: Whether the border should be shown.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showBorder(_ showBorder: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setShowBorder(showBorder: showBorder()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setShowTabs(showTabs:)
|
|
/// Sets whether to show the tabs for the notebook or not.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter showTabs: Whether tabs should be shown.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showTabs(_ showTabs: Bool) -> Self {
|
|
appending { w, _ in
|
|
w.setShowTabs(showTabs: showTabs)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setShowTabs(showTabs:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getShowTabs()
|
|
/// Sets whether to show the tabs for the notebook or not.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Bool` conforms to `Equatable` this binds in both directions: the widget's `notify` signal writes its current value back into the binding, so changes made in the UI propagate to the bound state. Each direction compares before writing, which terminates the echo after one hop. A value type that is not `Equatable` binds one way only, because the echo cannot be broken.
|
|
///
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showTabs(_ showTabs: Portico.Binding<Bool>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, showTabs, registry: ctx.registry, notifyDetail: "show-tabs",
|
|
read: { [w] in w.getShowTabs() },
|
|
write: { [w] v in w.setShowTabs(showTabs: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setShowTabs(showTabs:)
|
|
/// Sets whether to show the tabs for the notebook or not.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setShowTabs(showTabs:)`.
|
|
///
|
|
/// - Parameter showTabs: Whether tabs should be shown.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func showTabs(_ showTabs: @escaping () -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setShowTabs(showTabs: showTabs()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(static) | source: Gtk.Notebook.setTabPos(pos:)
|
|
/// Sets the edge at which the tabs are drawn.
|
|
///
|
|
/// Applied once at mount; use the `Binding` or closure overload for a value that changes.
|
|
///
|
|
/// - Parameter tabPos: Which side of the notebook holds the tabs.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func tabPos(_ tabPos: Gtk.PositionType) -> Self {
|
|
appending { w, _ in
|
|
w.setTabPos(pos: tabPos)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers -> bindingModifier(twoWay) | source: Gtk.Notebook.setTabPos(pos:), GObject.Object.connectNotify(detail:_:), Gtk.Notebook.getTabPos()
|
|
/// Sets the edge at which the tabs are drawn.
|
|
///
|
|
/// Applied at mount and re-applied on every change the binding publishes.
|
|
/// When `Gtk.PositionType` 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 tabPos(_ tabPos: Portico.Binding<Gtk.PositionType>) -> Self {
|
|
appending { w, ctx in
|
|
Portico.bindProperty(
|
|
w, tabPos, registry: ctx.registry, notifyDetail: "tab-pos",
|
|
read: { [w] in w.getTabPos() },
|
|
write: { [w] v in w.setTabPos(pos: v) }
|
|
)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generatePropertyModifiers(closure) | source: Gtk.Notebook.setTabPos(pos:)
|
|
/// Sets the edge at which the tabs are drawn.
|
|
///
|
|
/// The closure runs inside a `DependencyTracker`, so any `@State` it reads re-runs it and pushes the new value through `Gtk.Notebook.setTabPos(pos:)`.
|
|
///
|
|
/// - Parameter tabPos: Which side of the notebook holds the tabs.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func tabPos(_ tabPos: @escaping () -> Gtk.PositionType) -> Self {
|
|
appending { w, ctx in
|
|
let tracker = DependencyTracker { [w] in w.setTabPos(pos: tabPos()) }
|
|
tracker.run()
|
|
ctx.registry.add(tracker)
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectChangeCurrentPage(_:)
|
|
/// Emitted when the current page should be changed.
|
|
///
|
|
/// The default bindings for this signal are
|
|
/// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgUp</kbd>,
|
|
/// <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>PgDn</kbd>,
|
|
/// <kbd>Ctrl</kbd>+<kbd>PgUp</kbd> and <kbd>Ctrl</kbd>+<kbd>PgDn</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `change-current-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 onChangeCurrentPage(_ handler: @escaping (Int32) -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectChangeCurrentPage { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectCreateWindow(_:)
|
|
/// The ::create-window signal is emitted when a detachable
|
|
/// tab is dropped on the root window.
|
|
///
|
|
/// A handler for this signal can create a window containing
|
|
/// a notebook where the tab will be attached. It is also
|
|
/// responsible for moving/resizing the window and adding the
|
|
/// necessary properties to the notebook (e.g. the
|
|
/// `GtkNotebook`:group-name ).
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `create-window` 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 onCreateWindow(_ handler: @escaping (Gtk.Widget) -> Gtk.Notebook?) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectCreateWindow { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectFocusTab(_:)
|
|
/// Emitted when a tab should be focused.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `focus-tab` 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 onFocusTab(_ handler: @escaping (Gtk.NotebookTab) -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectFocusTab { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectMoveFocusOut(_:)
|
|
/// Emitted when focus was moved out.
|
|
///
|
|
/// The default bindings for this signal are
|
|
/// <kbd>Ctrl</kbd>+<kbd>Tab</kbd>,
|
|
/// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd>,
|
|
/// <kbd>Ctrl</kbd>+<kbd>←</kbd>, <kbd>Ctrl</kbd>+<kbd>→</kbd>,
|
|
/// <kbd>Ctrl</kbd>+<kbd>↑</kbd> and <kbd>Ctrl</kbd>+<kbd>↓</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `move-focus-out` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onMoveFocusOut(_ handler: @escaping (Gtk.DirectionType) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectMoveFocusOut { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectPageAdded(_:)
|
|
/// the ::page-added signal is emitted in the notebook
|
|
/// right after a page is added to the notebook.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `page-added` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onPageAdded(_ handler: @escaping (Gtk.Widget, UInt32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectPageAdded { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectPageRemoved(_:)
|
|
/// the ::page-removed signal is emitted in the notebook
|
|
/// right after a page is removed from the notebook.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `page-removed` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onPageRemoved(_ handler: @escaping (Gtk.Widget, UInt32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectPageRemoved { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectPageReordered(_:)
|
|
/// the ::page-reordered signal is emitted in the notebook
|
|
/// right after a page has been reordered.
|
|
///
|
|
/// - 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 (Gtk.Widget, UInt32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectPageReordered { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectReorderTab(_:)
|
|
/// Emitted when the tab should be reordered.
|
|
///
|
|
/// The default bindings for this signal are
|
|
/// <kbd>Alt</kbd>+<kbd>Home</kbd>, <kbd>Alt</kbd>+<kbd>End</kbd>,
|
|
/// <kbd>Alt</kbd>+<kbd>PgUp</kbd>, <kbd>Alt</kbd>+<kbd>PgDn</kbd>,
|
|
/// <kbd>Alt</kbd>+<kbd>←</kbd>, <kbd>Alt</kbd>+<kbd>→</kbd>,
|
|
/// <kbd>Alt</kbd>+<kbd>↑</kbd> and <kbd>Alt</kbd>+<kbd>↓</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `reorder-tab` 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 onReorderTab(_ handler: @escaping (Gtk.DirectionType, Bool) -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectReorderTab { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectSelectPage(_:)
|
|
/// Emitted when a page should be selected.
|
|
///
|
|
/// The default binding for this signal is <kbd>␣</kbd>.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `select-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 onSelectPage(_ handler: @escaping (Bool) -> Bool) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectSelectPage { _, a0 in handler(a0) })
|
|
}
|
|
}
|
|
|
|
// PorticoGen: generateModifierExtension -> generateSignalModifier | source: Gtk.Notebook.connectSwitchPage(_:)
|
|
/// Emitted when the user or a function changes the current page.
|
|
///
|
|
/// - Parameter handler: Invoked when the widget emits the `switch-page` signal. The closure receives the signal's arguments in order.
|
|
/// - Returns: A copy of this view with the modifier applied.
|
|
public func onSwitchPage(_ handler: @escaping (Gtk.Widget, UInt32) -> Void) -> Self {
|
|
appending { w, ctx in
|
|
ctx.registry.add(w.connectSwitchPage { _, a0, a1 in handler(a0, a1) })
|
|
}
|
|
}
|
|
|
|
}
|