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

Commit

Permalink
Add meta-sqlite to adwaita-swift
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Oct 3, 2024
1 parent 34f5b46 commit 0a6f104
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/AparokshaUI/Meta", branch: "main"),
.package(url: "https://github.com/AparokshaUI/meta-sqlite", branch: "main"),
.package(
url: "https://github.com/david-swift/LevenshteinTransformations",
from: "0.1.1"
Expand All @@ -40,7 +41,8 @@ let package = Package(
dependencies: [
"CAdw",
.product(name: "LevenshteinTransformations", package: "LevenshteinTransformations"),
.product(name: "Meta", package: "Meta")
.product(name: "Meta", package: "Meta"),
.product(name: "MetaSQLite", package: "meta-sqlite")
]
),
.executableTarget(
Expand Down
9 changes: 9 additions & 0 deletions Sources/Adwaita/Model/AdwaitaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//

import CAdw
import Foundation
@_exported import Meta
@_exported import MetaSQLite

/// The Meta app storage for the Adwaita backend.
public class AdwaitaApp: AppStorage {
Expand All @@ -31,6 +33,7 @@ public class AdwaitaApp: AppStorage {
/// - Parameter id: The identifier.
public required init(id: String) {
pointer = adw_application_new(id, G_APPLICATION_DEFAULT_FLAGS)?.cast()
DatabaseInformation.setPath(Self.userDataDir().appendingPathComponent("data.sqlite").path)
}

/// Copy a string to the clipboard.
Expand All @@ -39,6 +42,12 @@ public class AdwaitaApp: AppStorage {
gdk_clipboard_set_text(clipboard, text)
}

/// The directory used for storing user data.
/// - Returns: The URL.
public static func userDataDir() -> URL {
.init(fileURLWithPath: .init(cString: g_get_user_data_dir()))
}

/// Execute the app.
/// - Parameter setup: Set the scene elements up.
public func run(setup: @escaping () -> Void) {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Demo/CounterDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import Adwaita

struct CounterDemo: View {

@State private var count = 0
@State("count")
private var count = 0

var view: Body {
VStack {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Demo/Demo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ struct Demo: App {

struct DemoContent: WindowView {

@State private var selection: Page = .welcome
@State("selection")
private var selection: Page = .welcome
@State private var toast: Signal = .init()
@State private var sidebarVisible = true
@State private var width = 650
Expand Down

0 comments on commit 0a6f104

Please sign in to comment.