Replace GtkSpinner with AdwSpinner
All checks were successful
Deploy Docs / publish (push) Successful in 21m36s
SwiftLint / SwiftLint (push) Successful in 5s

This commit is contained in:
david-swift 2024-10-26 17:32:45 +02:00
parent ced07e4293
commit 356eec00a9
48 changed files with 72 additions and 84 deletions

View File

@ -2,7 +2,7 @@
// ActionRow.swift // ActionRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// AspectFrame.swift // AspectFrame.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Avatar.swift // Avatar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Banner.swift // Banner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Bin.swift // Bin.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Box.swift // Box.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Button.swift // Button.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ButtonContent.swift // ButtonContent.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Carousel.swift // Carousel.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// CenterBox.swift // CenterBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// CheckButton.swift // CheckButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Clamp.swift // Clamp.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ComboRow.swift // ComboRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// EntryRow.swift // EntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ExpanderRow.swift // ExpanderRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Fixed.swift // Fixed.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// FlowBox.swift // FlowBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// HeaderBar.swift // HeaderBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Label.swift // Label.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// LevelBar.swift // LevelBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// LinkButton.swift // LinkButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ListBox.swift // ListBox.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Menu.swift // Menu.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// NavigationView.swift // NavigationView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Overlay.swift // Overlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// OverlaySplitView.swift // OverlaySplitView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PasswordEntryRow.swift // PasswordEntryRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Picture.swift // Picture.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Popover.swift // Popover.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesGroup.swift // PreferencesGroup.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesPage.swift // PreferencesPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// PreferencesRow.swift // PreferencesRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ProgressBar.swift // ProgressBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ScrolledWindow.swift // ScrolledWindow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SearchBar.swift // SearchBar.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SearchEntry.swift // SearchEntry.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// Separator.swift // Separator.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SpinRow.swift // SpinRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,27 +2,36 @@
// Spinner.swift // Spinner.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw
import LevenshteinTransformations import LevenshteinTransformations
/// A `GtkSpinner` widget displays an icon-size spinning animation. /// A widget showing a loading spinner.
/// ///
/// It is often used as an alternative to a [class@Gtk.ProgressBar] /// <picture><source srcset="spinner-dark.png" media="(prefers-color-scheme: dark)"><img src="spinner.png" alt="spinner"></picture>
/// for displaying indefinite activity, instead of actual progress.
/// ///
/// ![An example GtkSpinner](spinner.png) /// The size of the spinner depends on the available size, never smaller than
/// 16×16 pixels and never larger than 64×64 pixels.
/// ///
/// To start the animation, use [method@Gtk.Spinner.start], to stop it /// Use the [property@Gtk.Widget:halign] and [property@Gtk.Widget:valign]
/// use [method@Gtk.Spinner.stop]. /// properties in combination with [property@Gtk.Widget:width-request] and
/// [property@Gtk.Widget:height-request] for fine sizing control.
/// ///
/// # CSS nodes /// For example, the following snippet shows the spinner at 48×48 pixels:
/// ///
/// `GtkSpinner` has a single CSS node with the name spinner. /// ```xml
/// When the animation is active, the :checked pseudoclass is /// <object class="AdwSpinner"><property name="halign">center</property><property name="valign">center</property><property name="width-request">48</property><property name="height-request">48</property></object>
/// added to this node. /// ```
///
/// See [class@SpinnerPaintable] for cases where using a widget is impractical or
/// impossible, such as [property@StatusPage:paintable].
///
/// ## CSS nodes
///
/// `AdwSpinner` has a single node with the name `image` and the style class
/// `.spinner`.
public struct Spinner: AdwaitaWidget { public struct Spinner: AdwaitaWidget {
/// Additional update functions for type extensions. /// Additional update functions for type extensions.
@ -30,12 +39,6 @@ public struct Spinner: AdwaitaWidget {
/// Additional appear functions for type extensions. /// Additional appear functions for type extensions.
var appearFunctions: [(ViewStorage, WidgetData) -> Void] = [] var appearFunctions: [(ViewStorage, WidgetData) -> Void] = []
/// The accessible role of the given `GtkAccessible` implementation.
///
/// The accessible role cannot be changed once set.
var accessibleRole: String?
/// Whether the spinner is spinning
var spinning: Bool?
/// Initialize `Spinner`. /// Initialize `Spinner`.
public init() { public init() {
@ -47,7 +50,7 @@ public struct Spinner: AdwaitaWidget {
/// - type: The view render data type. /// - type: The view render data type.
/// - Returns: The view storage. /// - Returns: The view storage.
public func container<Data>(data: WidgetData, type: Data.Type) -> ViewStorage where Data: ViewRenderData { public func container<Data>(data: WidgetData, type: Data.Type) -> ViewStorage where Data: ViewRenderData {
let storage = ViewStorage(gtk_spinner_new()?.opaque()) let storage = ViewStorage(adw_spinner_new()?.opaque())
for function in appearFunctions { for function in appearFunctions {
function(storage, data) function(storage, data)
} }
@ -65,9 +68,6 @@ public struct Spinner: AdwaitaWidget {
public func update<Data>(_ storage: ViewStorage, data: WidgetData, updateProperties: Bool, type: Data.Type) where Data: ViewRenderData { public func update<Data>(_ storage: ViewStorage, data: WidgetData, updateProperties: Bool, type: Data.Type) where Data: ViewRenderData {
storage.modify { widget in storage.modify { widget in
if let spinning, updateProperties, (storage.previousState as? Self)?.spinning != spinning {
gtk_spinner_set_spinning(widget, spinning.cBool)
}
} }
@ -79,20 +79,4 @@ public struct Spinner: AdwaitaWidget {
} }
} }
/// The accessible role of the given `GtkAccessible` implementation.
///
/// The accessible role cannot be changed once set.
public func accessibleRole(_ accessibleRole: String?) -> Self {
var newSelf = self
newSelf.accessibleRole = accessibleRole
return newSelf
}
/// Whether the spinner is spinning
public func spinning(_ spinning: Bool? = true) -> Self {
var newSelf = self
newSelf.spinning = spinning
return newSelf
}
} }

View File

@ -2,7 +2,7 @@
// SplitButton.swift // SplitButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// StatusPage.swift // StatusPage.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// SwitchRow.swift // SwitchRow.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToastOverlay.swift // ToastOverlay.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToggleButton.swift // ToggleButton.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// ToolbarView.swift // ToolbarView.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -2,7 +2,7 @@
// WindowTitle.swift // WindowTitle.swift
// Adwaita // Adwaita
// //
// Created by auto-generation on 22.10.24. // Created by auto-generation on 26.10.24.
// //
import CAdw import CAdw

View File

@ -8,6 +8,7 @@
// swiftlint:disable missing_docs implicitly_unwrapped_optional no_magic_numbers // swiftlint:disable missing_docs implicitly_unwrapped_optional no_magic_numbers
import Adwaita import Adwaita
import CAdw
import Foundation import Foundation
@main @main
@ -72,6 +73,7 @@ struct Demo: App {
@State private var sidebarVisible = true @State private var sidebarVisible = true
@State private var width = 650 @State private var width = 650
@State private var height = 550 @State private var height = 550
@State private var wide = true
@State private var maximized = false @State private var maximized = false
@State private var about = false @State private var about = false
var window: AdwaitaWindow var window: AdwaitaWindow
@ -125,6 +127,8 @@ struct Demo: App {
} }
.toast("This is a toast!", signal: toast) .toast("This is a toast!", signal: toast)
} }
.collapsed(!wide)
.breakpoint(minWidth: 550, matches: $wide)
.aboutDialog( .aboutDialog(
visible: $about, visible: $about,
app: "Demo", app: "Demo",

View File

@ -154,7 +154,8 @@ struct GenerationConfiguration {
.init( .init(
class: "NavigationView", class: "NavigationView",
excludeProperties: ["navigation-stack", "visible-page"] excludeProperties: ["navigation-stack", "visible-page"]
) ),
.init(class: "Spinner")
] ]
/// The Gtk widgets. /// The Gtk widgets.
@ -185,7 +186,6 @@ struct GenerationConfiguration {
excludeProperties: ["baseline-position", "orientation"], excludeProperties: ["baseline-position", "orientation"],
cast: true cast: true
), ),
.init(class: "Spinner"),
.init(class: "LevelBar", excludeProperties: ["mode", "orientation"]), .init(class: "LevelBar", excludeProperties: ["mode", "orientation"]),
.init( .init(
class: "ListBox", class: "ListBox",