185 lines
12 KiB
Swift
185 lines
12 KiB
Swift
// Generated by PorticoGen. DO NOT EDIT. See Sources/PorticoGen to make changes.
|
|
|
|
import Adw
|
|
import Gtk
|
|
import Gio
|
|
import Gdk
|
|
@_spi(Portico) import Portico
|
|
|
|
// PorticoGen: generateStruct | source: Gtk.AboutDialog
|
|
/// Displays information about a program.
|
|
///
|
|
/// The shown information includes the programs' logo, name, copyright,
|
|
/// website and license. It is also possible to give credits to the authors,
|
|
/// documenters, translators and artists who have worked on the program.
|
|
///
|
|
/// An about dialog is typically opened when the user selects the `About`
|
|
/// option from the `Help` menu. All parts of the dialog are optional.
|
|
///
|
|
/// <picture>
|
|
/// <source srcset="aboutdialot-dark.png" media="(prefers-color-scheme: dark)">
|
|
/// <img alt="An example GtkAboutDialog" src="aboutdialog.png">
|
|
/// </picture>
|
|
///
|
|
/// About dialogs often contain links and email addresses. `GtkAboutDialog`
|
|
/// displays these as clickable links. By default, it calls [method`Gtk`.FileLauncher.launch]
|
|
/// when a user clicks one. The behaviour can be overridden with the
|
|
/// [signal`Gtk`.AboutDialog::activate-link] signal.
|
|
///
|
|
/// To specify a person with an email address, use a string like
|
|
/// `Edgar Allan Poe <edgar`poe`.com>`. To specify a website with a title,
|
|
/// use a string like `GTK team https://www.gtk.org`.
|
|
///
|
|
/// To make constructing an about dialog as convenient as possible, you can
|
|
/// use the function [func`Gtk`.show_about_dialog] which constructs and shows
|
|
/// a dialog and keeps it around so that it can be shown again.
|
|
///
|
|
/// Note that GTK sets a default title of `_("About `s`")` on the dialog
|
|
/// window (where ``s`` is replaced by the name of the application, but in
|
|
/// order to ensure proper translation of the title, applications should
|
|
/// set the title property explicitly when constructing an about dialog,
|
|
/// as shown in the following example:
|
|
///
|
|
/// ```c
|
|
/// GFile *logo_file = g_file_new_for_path ("./logo.png");
|
|
/// GdkTexture *example_logo = gdk_texture_new_from_file (logo_file, NULL);
|
|
/// g_object_unref (logo_file);
|
|
///
|
|
/// gtk_show_about_dialog (NULL,
|
|
/// "program-name", "ExampleCode",
|
|
/// "logo", example_logo,
|
|
/// "title", _("About ExampleCode"),
|
|
/// NULL);
|
|
/// ```
|
|
///
|
|
/// ## Shortcuts and Gestures
|
|
///
|
|
/// `GtkAboutDialog` supports the following keyboard shortcuts:
|
|
///
|
|
/// - <kbd>Escape</kbd> closes the window.
|
|
///
|
|
/// ## CSS nodes
|
|
///
|
|
/// `GtkAboutDialog` has a single CSS node with the name `window` and style
|
|
/// class `.aboutdialog`.
|
|
///
|
|
/// A Portico view that mounts a `Gtk.AboutDialog`.
|
|
@MainActor public struct AboutDialog: View {
|
|
private let make: (MountContext) -> Gtk.AboutDialog
|
|
private var configure: [(Gtk.AboutDialog, MountContext) -> Void] = []
|
|
|
|
public var body: Never { fatalError() }
|
|
|
|
// PorticoGen: generateInits(static) | source: Gtk.AboutDialog.init()
|
|
/// Creates a new `GtkAboutDialog`.
|
|
///
|
|
/// 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.
|
|
/// 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 comments: Comments about the program.
|
|
/// - Parameter copyright: Copyright information for the program.
|
|
/// - Parameter license: The license of the program, as free-form text.
|
|
/// - Parameter licenseType: The license of the program.
|
|
/// - Parameter logo: A logo for the about box.
|
|
/// - Parameter logoIconName: A named icon to use as the logo for the about box.
|
|
/// - Parameter programName: The name of the program.
|
|
/// - Parameter systemInformation: Information about the system on which the program is running.
|
|
/// - Parameter translatorCredits: Credits to the translators.
|
|
/// - Parameter version: The version of the program.
|
|
/// - Parameter website: The URL for the link to the website of the program.
|
|
/// - Parameter websiteLabel: The label for the link to the website of the program.
|
|
/// - Parameter wrapLicense: Whether to wrap the text in the license dialog.
|
|
/// - Parameter application: The `GtkApplication` associated with the window.
|
|
/// - Parameter decorated: Whether the window should have a frame (also known as *decorations*).
|
|
/// - Parameter deletable: Whether the window frame should have a close button.
|
|
/// - Parameter destroyWithParent: If this window should be destroyed when the parent is destroyed.
|
|
/// - Parameter display: The display that will display this window.
|
|
/// - Parameter focusVisible: Whether 'focus rectangles' are currently visible in this window.
|
|
/// - Parameter gravity: The gravity to use when resizing the window programmatically.
|
|
/// - Parameter handleMenubarAccel: Whether the window frame should handle <kbd>F10</kbd> for activating menubars.
|
|
/// - Parameter hideOnClose: If this window should be hidden instead of destroyed when the user clicks the close button.
|
|
/// - Parameter iconName: Specifies the name of the themed icon to use as the window icon.
|
|
/// - Parameter mnemonicsVisible: Whether mnemonics are currently visible in this window.
|
|
/// - Parameter modal: If true, the window is modal.
|
|
/// - Parameter resizable: If true, users can resize the window.
|
|
/// - Parameter startupId: A write-only property for setting window's startup notification identifier.
|
|
/// - Parameter title: The title of the window.
|
|
/// - Parameter transientFor: The transient parent of the window.
|
|
/// - Parameter child: A `ViewBuilder` closure whose first view is mounted into the `child` slot.
|
|
/// - Parameter defaultWidget: A `ViewBuilder` closure whose first view is mounted into the `defaultWidget` slot.
|
|
/// - Parameter focusWidget: A `ViewBuilder` closure whose first view is mounted into the `focusWidget` slot.
|
|
/// - Parameter titlebar: A `ViewBuilder` closure whose first view is mounted into the `titlebar` slot.
|
|
/// - Parameter onActivateLink: Invoked when the widget emits the `activate-link` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onActivateDefault: Invoked when the widget emits the `activate-default` signal.
|
|
/// - Parameter onActivateFocus: Invoked when the widget emits the `activate-focus` signal.
|
|
/// - Parameter onCloseRequest: Invoked when the widget emits the `close-request` signal. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onEnableDebugging: Invoked when the widget emits the `enable-debugging` signal. The closure receives the signal's arguments in order. Its return value is forwarded to GTK as the signal's result.
|
|
/// - Parameter onKeysChanged: Invoked when the widget emits the `keys-changed` signal.
|
|
public init(comments: String? = nil, copyright: String? = nil, license: String? = nil, licenseType: Gtk.License? = nil, logo: Gtk.Paintable? = nil, logoIconName: String? = nil, programName: String? = nil, systemInformation: String? = nil, translatorCredits: String? = nil, version: String? = nil, website: String? = nil, websiteLabel: String? = nil, wrapLicense: Bool? = nil, application: Gtk.Application? = nil, decorated: Bool? = nil, deletable: Bool? = nil, destroyWithParent: Bool? = nil, display: Gtk.Display? = nil, focusVisible: Bool? = nil, gravity: Gtk.WindowGravity? = nil, handleMenubarAccel: Bool? = nil, hideOnClose: Bool? = nil, iconName: String? = nil, mnemonicsVisible: Bool? = nil, modal: Bool? = nil, resizable: Bool? = nil, startupId: String? = nil, title: String? = nil, transientFor: Gtk.Window? = nil, @ViewBuilder child: @escaping () -> [AnyView] = { [] }, @ViewBuilder defaultWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder focusWidget: @escaping () -> [AnyView] = { [] }, @ViewBuilder titlebar: @escaping () -> [AnyView] = { [] }, onActivateLink: ((String) -> Bool)? = nil, onActivateDefault: (() -> Void)? = nil, onActivateFocus: (() -> Void)? = nil, onCloseRequest: (() -> Bool)? = nil, onEnableDebugging: ((Bool) -> Bool)? = nil, onKeysChanged: (() -> Void)? = nil) {
|
|
make = { _ in Gtk.AboutDialog() }
|
|
configure.append { w, ctx in
|
|
if let comments { w.setComments(comments: comments) }
|
|
if let copyright { w.setCopyright(copyright: copyright) }
|
|
if let license { w.setLicense(license: license) }
|
|
if let licenseType { w.setLicenseType(licenseType: licenseType) }
|
|
if let logo { w.setLogo(logo: logo) }
|
|
if let logoIconName { w.setLogoIconName(iconName: logoIconName) }
|
|
if let programName { w.setProgramName(name: programName) }
|
|
if let systemInformation { w.setSystemInformation(systemInformation: systemInformation) }
|
|
if let translatorCredits { w.setTranslatorCredits(translatorCredits: translatorCredits) }
|
|
if let version { w.setVersion(version: version) }
|
|
if let website { w.setWebsite(website: website) }
|
|
if let websiteLabel { w.setWebsiteLabel(websiteLabel: websiteLabel) }
|
|
if let wrapLicense { w.setWrapLicense(wrapLicense: wrapLicense) }
|
|
if let application { w.setApplication(application: application) }
|
|
if let decorated { w.setDecorated(setting: decorated) }
|
|
if let deletable { w.setDeletable(setting: deletable) }
|
|
if let destroyWithParent { w.setDestroyWithParent(setting: destroyWithParent) }
|
|
if let display { w.setDisplay(display: display) }
|
|
if let focusVisible { w.setFocusVisible(setting: focusVisible) }
|
|
if let gravity { w.setGravity(gravity: gravity) }
|
|
if let handleMenubarAccel { w.setHandleMenubarAccel(handleMenubarAccel: handleMenubarAccel) }
|
|
if let hideOnClose { w.setHideOnClose(setting: hideOnClose) }
|
|
if let iconName { w.setIconName(name: iconName) }
|
|
if let mnemonicsVisible { w.setMnemonicsVisible(setting: mnemonicsVisible) }
|
|
if let modal { w.setModal(modal: modal) }
|
|
if let resizable { w.setResizable(resizable: resizable) }
|
|
if let startupId { w.setStartupId(startupId: startupId) }
|
|
if let title { w.setTitle(title: title) }
|
|
if let transientFor { w.setTransientFor(parent: transientFor) }
|
|
if let v = Portico.mountSlotChild(child, ctx, onUpdate: { v in w.setChild(child: v) }) { w.setChild(child: v) }
|
|
if let v = Portico.mountSlotChild(defaultWidget, ctx, onUpdate: { v in w.setDefaultWidget(defaultWidget: v) }) { w.setDefaultWidget(defaultWidget: v) }
|
|
if let v = Portico.mountSlotChild(focusWidget, ctx, onUpdate: { v in w.setFocus(focus: v) }) { w.setFocus(focus: v) }
|
|
if let v = Portico.mountSlotChild(titlebar, ctx, onUpdate: { v in w.setTitlebar(titlebar: v) }) { w.setTitlebar(titlebar: v) }
|
|
if let onActivateLink { ctx.registry.add(w.connectActivateLink { _, a0 in onActivateLink(a0) }) }
|
|
if let onActivateDefault { ctx.registry.add(w.connectActivateDefault { _ in onActivateDefault() }) }
|
|
if let onActivateFocus { ctx.registry.add(w.connectActivateFocus { _ in onActivateFocus() }) }
|
|
if let onCloseRequest { ctx.registry.add(w.connectCloseRequest { _ in onCloseRequest() }) }
|
|
if let onEnableDebugging { ctx.registry.add(w.connectEnableDebugging { _, a0 in onEnableDebugging(a0) }) }
|
|
if let onKeysChanged { ctx.registry.add(w.connectKeysChanged { _ in onKeysChanged() }) }
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension AboutDialog: WidgetView {
|
|
public typealias Target = Gtk.AboutDialog
|
|
|
|
@_spi(Portico) public func appending(
|
|
_ step: @escaping (Gtk.AboutDialog, MountContext) -> Void
|
|
) -> Self {
|
|
var c = self
|
|
c.configure.append(step)
|
|
return c
|
|
}
|
|
}
|
|
|
|
@_spi(Portico) extension AboutDialog: Mountable {
|
|
@_spi(Portico) public func mount(_ ctx: MountContext) -> Gtk.Widget {
|
|
let w = make(ctx)
|
|
for step in configure { step(w, ctx) }
|
|
return w
|
|
}
|
|
}
|