// // AdwaitaAboutDialogConfig.swift // Adwaita // // Created by lambdaclan on 09.01.2026. // import CAdw import Foundation /// URL links for about dialog. public typealias AboutLink = (title: String, url: String) /// Initialization options for the about dialog wrapper. public struct AdwaitaAboutDialogConfig { /// Example HTML release notes used for demonstrating how the About dialog /// renders structured content such as paragraphs, lists, and inline markup. /// This sample is intended for testing, previews, and documentation. public static let demoReleaseNotes = """

This template supports three structures: paragraphs using <p>, ordered lists using <ol>, and unordered lists using <ul>. Both list types must contain list items marked with <li>.

Within paragraphs and list items, you may use <em> to apply emphasis(italic text) and <code> to mark inline code for monospaced text. These inline styles are supported only inside those elements.

Any text placed outside <p>, <ol>, <ul>, or <li> tags is ignored by the template processor.

  1. Ordered list items represent numbered content and may include <em> for emphasis or <code> for inline code.
  2. They follow the same rules as paragraphs regarding allowed inline styles.
""" /// Example Pango‑markup comments showcasing how styled text, links, and /// formatting behave inside the About dialog’s “Details” section. /// Useful for previews, testing, and as a reference for developers who want /// to embed formatted text in their own dialogs. public static let demoComments = """ This text demonstrates basic Pango markup along with helpful documentation links. Comments shown in an Adwaita AboutDialog will appear on the Details page. They can be long and detailed, and they may include links and Pango markup for formatting. Pango markup supports tags like: • bolditaliccolored text Full reference: Pango Markup Reference Example markup: Demo Title Highlighted text Underlined text Useful links: • Adwaita‑Swift Documentation You can embed these links directly in your UI using Pango markup. """ /// The app's name. public var appName: String? /// The developer's name. public var developer: String? /// The app version. public var version: String? /// The app icon. public var icon: Icon? /// The app's website. public var website: URL? /// The link for opening issues. public var issues: URL? /// Additional links related to the app. public var links: [AboutLink]? /// The app's copyright information. public var copyright: String? /// The app's license. public var license: String? /// The app's release notes public var releaseNotes: String? /// The comments about the application public var comments: String? /// Initialize the about dialog wrapper. /// - Parameters: /// - appName: The app's name. /// - developer: The developer's name. /// - version: The version string. /// - icon: The app icon. /// - website: The app's website. /// - issues: Website for reporting issues. /// - links: Additional links related to the app. /// - copyright: The app's copyright information. /// - license: The app's license. /// - releaseNotes: The app's release notes. /// - comments: The comments about the application. public init( appName: String? = nil, developer: String? = nil, version: String? = nil, icon: Icon? = nil, website: URL? = nil, issues: URL? = nil, links: [AboutLink]? = nil, copyright: String? = nil, license: String? = nil, releaseNotes: String? = nil, comments: String? = nil ) { self.appName = appName self.developer = developer self.version = version self.icon = icon self.website = website self.issues = issues self.links = links self.copyright = copyright self.license = license self.releaseNotes = releaseNotes self.comments = comments } /// Apply the configuration values to the given dialog. /// - Parameters: /// - dialog: The underlying Adwaita dialog instance to update with the configuration. func apply(to dialog: OpaquePointer) { let handlers: [(String?, (OpaquePointer, UnsafePointer?) -> Void)] = [ (appName, adw_about_dialog_set_application_name), (developer, adw_about_dialog_set_developer_name), (version, adw_about_dialog_set_version), (icon?.string, adw_about_dialog_set_application_icon), (website?.absoluteString, adw_about_dialog_set_website), (issues?.absoluteString, adw_about_dialog_set_issue_url), (copyright, adw_about_dialog_set_copyright), (license, adw_about_dialog_set_license), (releaseNotes, adw_about_dialog_set_release_notes), (comments, adw_about_dialog_set_comments) ] for (value, action) in handlers { value.map { action(dialog, $0) } } links?.forEach { (title: String, url: String) in adw_about_dialog_add_link(dialog, title, url) } } }