From 407fca10fff5376ee54b65383844e69401c77d16 Mon Sep 17 00:00:00 2001 From: Ira Limitanei Date: Fri, 16 Jan 2026 11:23:27 +0900 Subject: [PATCH] Add about dialog configuration struct --- .../Model/AdwaitaAboutDialogConfig.swift | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Sources/Adwaita/Model/AdwaitaAboutDialogConfig.swift diff --git a/Sources/Adwaita/Model/AdwaitaAboutDialogConfig.swift b/Sources/Adwaita/Model/AdwaitaAboutDialogConfig.swift new file mode 100644 index 0000000..5674ade --- /dev/null +++ b/Sources/Adwaita/Model/AdwaitaAboutDialogConfig.swift @@ -0,0 +1,136 @@ +// +// AdwaitaAboutDialogConfig.swift +// Adwaita +// +// Created by lambdaclan on 09.01.2026. +// + +import CAdw +import Foundation + +/// 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. +
  3. They follow the same rules as paragraphs regarding allowed inline styles.
  4. +
+ + """ + + /// 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: + • bold + • italic + • colored 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? + /// 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. + /// - 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, + 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.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), + (releaseNotes, adw_about_dialog_set_release_notes), + (comments, adw_about_dialog_set_comments) + ] + + for (value, action) in handlers { + value.map { action(dialog, $0) } + } + } + +}