From f53c19404523366f239eb7211663095c6109fdf0 Mon Sep 17 00:00:00 2001 From: david-swift Date: Sat, 18 May 2024 12:06:44 +0200 Subject: [PATCH] Add modifier for window devel style --- Sources/Adwaita/Window/Window.swift | 14 ++++++++++++++ Tests/Demo.swift | 1 + 2 files changed, 15 insertions(+) diff --git a/Sources/Adwaita/Window/Window.swift b/Sources/Adwaita/Window/Window.swift index 5576124..943f194 100644 --- a/Sources/Adwaita/Window/Window.swift +++ b/Sources/Adwaita/Window/Window.swift @@ -43,6 +43,8 @@ public struct Window: WindowScene { var setDefaultSize = false /// Whether the window is maximized. var maximized: Binding? + /// Whether the window uses the development style. + var devel = false /// Create a window type with a certain identifier and user interface. /// - Parameters: @@ -66,6 +68,9 @@ public struct Window: WindowScene { windowStorage.destroy = true } windowStorage.parentID = parentID + if devel { + gtk_widget_add_css_class(window.pointer?.cast(), "devel") + } return windowStorage } @@ -341,6 +346,15 @@ public struct Window: WindowScene { return newSelf } + /// Whether the window used the development style. + /// - Parameter active: Whether the style is active. + /// - Returns: The window. + public func devel(_ active: Bool = true) -> Self { + var newSelf = self + newSelf.devel = active + return newSelf + } + } // swiftlint:enable discouraged_optional_collection diff --git a/Tests/Demo.swift b/Tests/Demo.swift index 9388e82..212532a 100644 --- a/Tests/Demo.swift +++ b/Tests/Demo.swift @@ -22,6 +22,7 @@ struct Demo: App { Window(id: "main") { window in DemoContent(window: window, app: app, pictureURL: pictureURL) } + .devel() HelperWindows() FileDialog(importer: "picture", extensions: ["jpg", "jpeg", "png", "svg"]) { pictureURL = $0 } onClose: { } }