Migrate from SwiftGui to Libadwaita

This commit is contained in:
david-swift 2023-11-26 14:50:20 +01:00
parent 490e1a5be8
commit 7a97d36585
49 changed files with 88 additions and 88 deletions

View File

@ -14,9 +14,9 @@ body:
- type: textarea
attributes:
label: Name the equivalents in GTUI.
label: Name the equivalents in Libadwaita.
placeholder: >-
A list of the equivalents in the GTUI library in SwiftGui (see dependencies).
A list of the equivalents in the Libadwaita library (see dependencies).
validations:
required: true

View File

@ -96,7 +96,7 @@ disabled_rules:
custom_rules:
github_issue:
name: 'GitHub Issue'
regex: '//.(TODO|FIXME):.(?!.*(https://github\.com/david-swift/Adwaita/issues/\d))'
regex: '//.(TODO|FIXME):.(?!.*(https://github\.com/AparokshaUI/Adwaita/issues/\d))'
message: 'The related GitHub issue must be included in a TODO or FIXME.'
severity: warning

View File

@ -9,7 +9,7 @@ Just open a new issue on GitHub and describe the bug. It helps if your descripti
Just open a new issue on GitHub and describe the idea. Thank you very much for your contribution!
### Suggest a New Component
If you want to be able to access a component from Libadwaita or GTK that is currently not available in Adwaita, you can add it to [SwiftGui](https://github.com/JCWasmx86/SwiftGui).
If you want to be able to access a component from Libadwaita or GTK that is currently not available in Adwaita, you can add it to [Libadwaita](https://github.com/AparokshaUI/Libadwaita).
If you want to add an Adwaita interface for an already existing GTUI widget, open an issue.
## Pull Requests

View File

@ -5,5 +5,5 @@
## Methods
### `vertical()`
Initialize a vertical `GTUI.Box`.
Initialize a vertical `Libadwaita.Box`.
- Returns: The vertical box.

View File

@ -5,14 +5,14 @@
## Methods
### `update(_:modifiers:)`
A `GTUI.NativeWidgetPeer` is static.
A `Libadwaita.NativeWidgetPeer` is static.
- Parameters:
- storage: The view storage.
- modifiers: Modify views before being updated.
### `container(modifiers:)`
A `GTUI.NativeWidgetPeer`'s container is itself.
A `Libadwaita.NativeWidgetPeer`'s container is itself.
- Parameter modifiers: Modify views before being updated.
- Returns: The view storage.

View File

@ -8,7 +8,7 @@ A structure conforming to `App` is the entry point of your app.
@main
struct Test: App {
let id = "io.github.david-swift.TestApp"
let id = "io.github.AparokshaUI.TestApp"
var app: GTUIApp!
var scene: Scene {

View File

@ -18,12 +18,12 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/david-swift/SwiftGui", from: "0.1.0")
.package(url: "https://github.com/AparokshaUI/Libadwaita", from: "0.1.0")
],
targets: [
.target(
name: "Adwaita",
dependencies: [.product(name: "GTUI", package: "swiftgui")]
dependencies: [.product(name: "Libadwaita", package: "Libadwaita")]
),
.executableTarget(
name: "Swift Adwaita Demo",

View File

@ -8,7 +8,7 @@
User Manual
</a>
·
<a href="https://github.com/david-swift/Adwaita">
<a href="https://github.com/AparokshaUI/Adwaita">
GitHub
</a>
·
@ -88,7 +88,7 @@ If you want to use _Adwaita_ in a project, but there are widgets missing, open a
| Syntax | Description |
| ---------------------------- | --------------------------------------------------------------------------------------- |
| `inspect(_:)` | Edit the underlying [GTUI][10] widget. |
| `inspect(_:)` | Edit the underlying [Libadwaita][10] widget. |
| `padding(_:_:)` | Add empty space around a view. |
| `hexpand(_:)` | Enable or disable the horizontal expansion of a view. |
| `vexpand(_:)` | Enable or disable the vertical expansion of a view. |
@ -168,7 +168,7 @@ brew install libadwaita
2. Open the `Package.swift` file.
3. Into the `Package` initializer, under `dependencies`, paste:
```swift
.package(url: "https://github.com/david-swift/Adwaita", from: "0.1.0")
.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.0")
```
## Usage
@ -189,7 +189,7 @@ brew install libadwaita
## Thanks
### Dependencies
- [SwiftGui][18] licensed under the [GPL-3.0 license][19]
- [Libadwaita][18] licensed under the [GPL-3.0 license][19]
### Other Thanks
- The [contributors][20]
@ -205,8 +205,8 @@ brew install libadwaita
[6]: #thanks
[7]: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/index.html
[8]: https://docs.gtk.org/gtk4/
[9]: https://github.com/david-swift/Adwaita/issues
[10]: https://github.com/JCWasmx86/SwiftGui
[9]: https://github.com/AparokshaUI/Adwaita/issues
[10]: https://github.com/AparokshaUI/Libadwaita
[11]: https://brew.sh
[12]: user-manual/GettingStarted.md
[13]: user-manual/Basics/HelloWorld.md
@ -214,8 +214,8 @@ brew install libadwaita
[15]: user-manual/Basics/Windows.md
[16]: user-manual/Basics/KeyboardShortcuts.md
[17]: user-manual/Advanced/CreatingWidgets.md
[18]: https://github.com/JCWasmx86/SwiftGui
[19]: https://github.com/JCWasmx86/SwiftGui/blob/main/COPYING
[18]: https://github.com/AparokshaUI/Libadwaita
[19]: https://github.com/AparokshaUI/Libadwaita/blob/main/LICENSE.md
[20]: Contributors.md
[21]: https://github.com/realm/SwiftLint
[22]: https://github.com/apple/swift

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23.
//
import GTUI
import Libadwaita
/// A button widget for menus.
public struct MenuButton: MenuItem {
@ -35,7 +35,7 @@ public struct MenuButton: MenuItem {
/// - menu: The menu.
/// - app: The application containing the menu.
/// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
if let window, preferApplicationWindow {
_ = menu.append(label, window: window, shortcut: shortcut, handler: handler)
} else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23.
//
import GTUI
import Libadwaita
/// A section for menus.
public struct MenuSection: MenuItem {
@ -24,8 +24,8 @@ public struct MenuSection: MenuItem {
/// - menu: The menu.
/// - app: The application containing the menu.
/// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let section = GTUI.Menu()
public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let section = Libadwaita.Menu()
_ = menu.append("", section: section)
for element in sectionContent {
element.addMenuItems(menu: section, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23.
//
import GTUI
import Libadwaita
/// A submenu widget.
public struct Submenu: MenuItem {
@ -29,8 +29,8 @@ public struct Submenu: MenuItem {
/// - menu: The menu.
/// - app: The application containing the menu.
/// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let submenu = GTUI.Menu()
public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let submenu = Libadwaita.Menu()
_ = menu.append(label, submenu: submenu)
for element in submenuContent {
element.addMenuItems(menu: submenu, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 06.08.23.
//
import GTUI
import Libadwaita
extension Array: View where Element == View {

View File

@ -5,17 +5,17 @@
// Created by david-swift on 05.08.23.
//
import GTUI
import Libadwaita
extension NativeWidgetPeer: Widget {
/// A `GTUI.NativeWidgetPeer` is static.
/// A `Libadwaita.NativeWidgetPeer` is static.
/// - Parameters:
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { }
/// A `GTUI.NativeWidgetPeer`'s container is itself.
/// A `Libadwaita.NativeWidgetPeer`'s container is itself.
/// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23.
//
import GTUI
import Libadwaita
/// A structure conforming to `App` is the entry point of your app.
///
@ -13,7 +13,7 @@ import GTUI
/// @main
/// struct Test: App {
///
/// let id = "io.github.david-swift.TestApp"
/// let id = "io.github.AparokshaUI.TestApp"
/// var app: GTUIApp!
///
/// var scene: Scene {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23.
//
import GTUI
import Libadwaita
/// The GTUI application.
public class GTUIApp: Application {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23.
//
import GTUI
import Libadwaita
/// A structure representing the content for a certain menu item type.
public protocol MenuItem: MenuItemGroup {
@ -15,7 +15,7 @@ public protocol MenuItem: MenuItemGroup {
/// - menu: The menu.
/// - app: The application containing the menu.
/// - window: The application window containing the menu.
func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?)
func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?)
}

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23.
//
import GTUI
import Libadwaita
/// A structure conforming to `MenuItemGroup` can be added to the content accepting a menu.
public protocol MenuItemGroup {
@ -19,7 +19,7 @@ extension MenuItemGroup {
/// Add the menu items described by the group to a menu.
/// - Parameter menu: The menu.
func addMenuItems(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
func addMenuItems(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
for element in content {
if let item = element as? MenuItem {
item.addMenuItem(menu: menu, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23.
//
import GTUI
import Libadwaita
/// A structure conforming to `View` is referred to as a view.
/// It can be part of a body.

View File

@ -5,7 +5,7 @@
// Created by david-swift on 31.08.23.
//
import GTUI
import Libadwaita
/// Store a rendered view in a view storage.
public class ViewStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 16.08.23.
//
import GTUI
import Libadwaita
/// A widget is a view that know about its GTUI widget.
public protocol Widget: View {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 19.10.23.
//
import GTUI
import Libadwaita
/// A GTUI application window.
public typealias GTUIApplicationWindow = GTUI.ApplicationWindow
public typealias GTUIApplicationWindow = Libadwaita.ApplicationWindow

View File

@ -5,7 +5,7 @@
// Created by david-swift on 12.10.23.
//
import GTUI
import Libadwaita
/// A GTUI window.
public typealias GTUIWindow = GTUI.Window
public typealias GTUIWindow = Libadwaita.Window

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23.
//
import GTUI
import Libadwaita
/// A structure representing the content for a certain window type.
public protocol WindowScene: WindowSceneGroup {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 31.08.23.
//
import GTUI
import Libadwaita
/// A storage for an app's window.
public class WindowStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23.
//
import GTUI
import Libadwaita
/// A button widget.
public struct Button: Widget {
@ -44,7 +44,7 @@ public struct Button: Widget {
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let button = storage.view as? GTUI.Button {
if let button = storage.view as? Libadwaita.Button {
let content = button.getContent()
if let label {
if icon == nil {
@ -64,9 +64,9 @@ public struct Button: Widget {
/// - Returns: The button's view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {
if let icon {
return .init(GTUI.Button(label, icon: icon).handler(handler))
return .init(Libadwaita.Button(label, icon: icon).handler(handler))
} else {
return .init(GTUI.Button(label ?? .init()).handler(handler))
return .init(Libadwaita.Button(label ?? .init()).handler(handler))
}
}

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.08.23.
//
import GTUI
import Libadwaita
/// An equivalent to GtkStack for two views.
public struct EitherView: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23.
//
import GTUI
import Libadwaita
/// A horizontal GtkBox equivalent.
public struct HStack: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23.
//
import GTUI
import Libadwaita
/// A header bar widget.
public struct HeaderBar: Widget {
@ -62,7 +62,7 @@ public struct HeaderBar: Widget {
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let bar = storage.view as? GTUI.HeaderBar {
if let bar = storage.view as? Libadwaita.HeaderBar {
_ = bar.showTitleButtons(titleButtons)
}
start.update(storage.content[startID] ?? [], modifiers: modifiers)
@ -76,7 +76,7 @@ public struct HeaderBar: Widget {
/// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {
let bar: GTUI.HeaderBar = .init()
let bar: Libadwaita.HeaderBar = .init()
var startContent: [ViewStorage] = []
var endContent: [ViewStorage] = []
for element in start {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 25.09.23.
//
import GTUI
import Libadwaita
/// A list box widget.
public struct List<Element>: Widget where Element: Identifiable {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 21.10.23.
//
import GTUI
import Libadwaita
/// A menu button widget.
public struct Menu: Widget {
@ -67,7 +67,7 @@ public struct Menu: Widget {
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let button = storage.view as? GTUI.MenuButton {
if let button = storage.view as? Libadwaita.MenuButton {
let content = button.getContent()
if let label {
if icon == nil {
@ -86,7 +86,7 @@ public struct Menu: Widget {
/// - Parameter modifiers: Modify views before being updated.
/// - Returns: The button's view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {
let button: GTUI.MenuButton
let button: Libadwaita.MenuButton
if let icon {
button = .init(label, icon: icon)
} else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 12.10.23.
//
import GTUI
import Libadwaita
/// A horizontal AdwClamp equivalent.
struct Clamp: Widget {
@ -20,7 +20,7 @@ struct Clamp: Widget {
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let clamp = storage.view as? GTUI.Clamp {
if let clamp = storage.view as? Libadwaita.Clamp {
_ = clamp.maximumSize(maxSize)
}
if let storage = storage.content[.mainContent]?[safe: 0] {
@ -33,7 +33,7 @@ struct Clamp: Widget {
/// - Returns: The view storage.
func container(modifiers: [(View) -> View]) -> ViewStorage {
let container = content.storage(modifiers: modifiers)
let clamp: GTUI.Clamp = .init(container.view)
let clamp: Libadwaita.Clamp = .init(container.view)
_ = clamp.maximumSize(maxSize)
return .init(clamp, content: [.mainContent: [container]])
}

View File

@ -5,7 +5,7 @@
// Created by david-swift on 11.11.23.
//
import GTUI
import Libadwaita
/// A widget which replaces views of a specific type in its content.
struct ContentModifier<Content>: Widget where Content: View {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23.
//
import GTUI
import Libadwaita
/// A widget which executes a custom code on the GTUI widget when being created and updated.
struct InspectorWrapper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 11.11.23.
//
import GTUI
import Libadwaita
/// Remove all of the content modifiers for the wrapped views.
struct ModifierStopper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 24.09.23.
//
import GTUI
import Libadwaita
/// A toolbar view widget.
struct ToolbarView: Widget {
@ -27,7 +27,7 @@ struct ToolbarView: Widget {
/// - Returns: The view storage.
func container(modifiers: [(View) -> View]) -> ViewStorage {
let content = content.storage(modifiers: modifiers)
let view = GTUI.ToolbarView(content.view)
let view = Libadwaita.ToolbarView(content.view)
var toolbarContent: [ViewStorage] = []
for item in toolbar() {
let storage = item.storage(modifiers: modifiers)
@ -59,7 +59,7 @@ struct ToolbarView: Widget {
self.toolbar()[safe: index]?.updateStorage(content, modifiers: modifiers)
}
}
if let view = storage.view as? GTUI.ToolbarView {
if let view = storage.view as? Libadwaita.ToolbarView {
if bottom {
view.setRevealBottomBar(visible)
} else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23.
//
import GTUI
import Libadwaita
/// A widget which executes a custom code when being updated.
struct UpdateObserver: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 24.09.23.
//
import GTUI
import Libadwaita
/// A navigation split view widget.
public struct NavigationSplitView: Widget {
@ -33,7 +33,7 @@ public struct NavigationSplitView: Widget {
/// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage {
let splitView: GTUI.NavigationSplitView = .init()
let splitView: Libadwaita.NavigationSplitView = .init()
var content: [String: [ViewStorage]] = [:]
let sidebar = sidebar().widget(modifiers: modifiers).container(modifiers: modifiers)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23.
//
import GTUI
import Libadwaita
/// A GtkScrolledWindow equivalent.
public struct ScrollView: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23.
//
import GTUI
import Libadwaita
/// A storage for `@State` properties.
public struct StateWrapper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 25.09.23.
//
import GTUI
import Libadwaita
/// A status page widget.
public struct StatusPage: Widget {
@ -42,7 +42,7 @@ public struct StatusPage: Widget {
/// - storage: The view storage.
/// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let statusPage = storage.view as? GTUI.StatusPage {
if let statusPage = storage.view as? Libadwaita.StatusPage {
_ = statusPage.title(title).description(description).icon(icon)
}
if let storage = storage.content[.mainContent]?.first {
@ -56,7 +56,7 @@ public struct StatusPage: Widget {
public func container(modifiers: [(View) -> View]) -> ViewStorage {
let child = content.widget(modifiers: []).container(modifiers: modifiers)
return .init(
GTUI.StatusPage().title(title).description(description).icon(icon).child(child.view),
Libadwaita.StatusPage().title(title).description(description).icon(icon).child(child.view),
content: [.mainContent: [child]]
)
}

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23.
//
import GTUI
import Libadwaita
/// A text widget.
public struct Text: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23.
//
import GTUI
import Libadwaita
/// A GtkBox equivalent.
public struct VStack: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 14.09.23.
//
import GTUI
import Libadwaita
/// A structure representing an application window type.
///

View File

@ -8,7 +8,7 @@
// swiftlint:disable missing_docs
import Adwaita
import GTUI
import Libadwaita
struct CounterDemo: View {

View File

@ -12,7 +12,7 @@ import Adwaita
@main
struct Demo: App {
let id = "io.github.david-swift.Demo"
let id = "io.github.AparokshaUI.Demo"
var app: GTUIApp!
@State private var toolbar = false

View File

@ -8,7 +8,7 @@
// swiftlint:disable missing_docs implicitly_unwrapped_optional
import Adwaita
import GTUI
import Libadwaita
enum Page: String, Identifiable, CaseIterable {
@ -33,7 +33,7 @@ enum Page: String, Identifiable, CaseIterable {
}
}
var icon: GTUI.Icon? {
var icon: Libadwaita.Icon? {
switch self {
case .welcome:
return .default(icon: .gnomeAdwaita1Demo)

View File

@ -2,7 +2,7 @@
Widgets are special views that do not provide a collection of other views as a content,
but have functions that are called when creating or updating the view.
Normally, a widget manages a GTK or Libadwaita widget using [SwiftGui][1].
Normally, a widget manages a GTK or Libadwaita widget using [Libadwaita][1].
## Recreate the `Text` widget
In this tutorial, we will recreate the text widget.
@ -40,7 +40,7 @@ func container() -> ViewStorage {
.init(MarkupLabel(self.text))
}
```
`MarkupLabel` is defined in [SwiftGui][1].
`MarkupLabel` is defined in [Libadwaita][1].
## The `update(_:)` Function
Whenever a state of the app changes, the `update(_:)` function of the widget gets called.
@ -60,5 +60,5 @@ In that case, use the `ViewStorage`'s `content` property for storing their view
In the `update(_:)` function, update the children's storages.
An example showcasing how to implement containers is the [VStack][2].
[1]: https://github.com/JCWasmx86/SwiftGui
[1]: https://github.com/AparokshaUI/Libadwaita
[2]: ../../Sources/Adwaita/View/VStack.swift

View File

@ -15,7 +15,7 @@ This is a beginner tutorial. We will create a simple "Hello, world!" app using _
1. Open the `Package.swift` file.
2. Add the following line of code after `name: "HelloWorld",`:
```
dependencies: [.package(url: "https://github.com/david-swift/Adwaita", from: "0.1.1")],
dependencies: [.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.1")],
```
## Create the App

View File

@ -16,4 +16,4 @@ Install `libadwaita-devel` or `libadwaita` (or something similar, based on the p
Adwaita is an open source project. Visit the [GitHub repository][2] for bug reports, feature requests, pull requests and more information.
[1]: https://brew.sh
[2]: https://github.com/david-swift/Adwaita
[2]: https://github.com/AparokshaUI/Adwaita