Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Add modifier for window devel style
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed May 18, 2024
1 parent be9cf99 commit f53c194
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/Adwaita/Window/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public struct Window: WindowScene {
var setDefaultSize = false
/// Whether the window is maximized.
var maximized: Binding<Bool>?
/// Whether the window uses the development style.
var devel = false

/// Create a window type with a certain identifier and user interface.
/// - Parameters:
Expand All @@ -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
}

Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions Tests/Demo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: { }
}
Expand Down

0 comments on commit f53c194

Please sign in to comment.