Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
9C3E1A07284E8E020042BEC0 /* WelcomeModuleExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C3E1A06284E8E020042BEC0 /* WelcomeModuleExtensions.swift */; };
B658FB3427DA9E1000EA4DBD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B658FB3327DA9E1000EA4DBD /* Assets.xcassets */; };
B658FB3727DA9E1000EA4DBD /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B658FB3627DA9E1000EA4DBD /* Preview Assets.xcassets */; };
B69542E128D5788B00EAD898 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = B69542E028D5788B00EAD898 /* Sparkle */; };
B6EE989027E8879A00CDD8AB /* InspectorSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6EE988F27E8879A00CDD8AB /* InspectorSidebar.swift */; };
B6EE989227E887C600CDD8AB /* InspectorSidebarToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6EE989127E887C600CDD8AB /* InspectorSidebarToolbar.swift */; };
D7012EE827E757850001E1EF /* FindNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7012EE727E757850001E1EF /* FindNavigator.swift */; };
Expand Down Expand Up @@ -265,6 +266,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B69542E128D5788B00EAD898 /* Sparkle in Frameworks */,
0483E34D27FCC46600354AC0 /* ExtensionsStore in Frameworks */,
64B64EDE27F7B79400C400F1 /* About in Frameworks */,
043BCF07281DA2F5000AC47C /* TabBar in Frameworks */,
Expand Down Expand Up @@ -680,6 +682,7 @@
043BCF06281DA2F5000AC47C /* TabBar */,
FA6BA6F0282ACAD600019309 /* Keybindings */,
20AFDC7E28206701001A4FC7 /* Git */,
B69542E028D5788B00EAD898 /* Sparkle */,
);
productName = CodeEdit;
productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */;
Expand Down Expand Up @@ -759,6 +762,7 @@
packageReferences = (
04C3256728034F3D00C8DA2D /* XCRemoteSwiftPackageReference "CodeEditKit" */,
2816F592280CF50500DD548B /* XCRemoteSwiftPackageReference "CodeEditSymbols" */,
B69542DF28D5788B00EAD898 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1446,6 +1450,14 @@
kind = branch;
};
};
B69542DF28D5788B00EAD898 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -1519,6 +1531,11 @@
isa = XCSwiftPackageProductDependency;
productName = About;
};
B69542E028D5788B00EAD898 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = B69542DF28D5788B00EAD898 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
D70F5E2B27E4E8CF004EE4B9 /* WelcomeModule */ = {
isa = XCSwiftPackageProductDependency;
productName = WelcomeModule;
Expand Down
3 changes: 3 additions & 0 deletions CodeEdit/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class CodeEditApplication: NSApplication {

@NSApplicationMain
final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
var updater: SoftwareUpdater = SoftwareUpdater()

func applicationWillFinishLaunching(_ notification: Notification) {
_ = CodeEditDocumentController.shared
}
Expand Down Expand Up @@ -219,6 +221,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
toolbarIcon: NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil)!
) {
GeneralPreferencesView()
.environmentObject(updater)
},
Preferences.Pane(
identifier: Preferences.PaneIdentifier("Accounts"),
Expand Down
16 changes: 8 additions & 8 deletions CodeEdit/Documents/CodeEditWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ final class CodeEditWindowController: NSWindowController, NSToolbarDelegate {
func registerCommands() {
CommandManager.shared.addCommand(
name: "Quick Open",
title: "Quick Open",
id: "quick_open",
command: ClosureWrapper(closure: {
title: "Quick Open",
id: "quick_open",
command: ClosureWrapper(closure: {
self.openQuickly(self)
})
)

CommandManager.shared.addCommand(
name: "Toggle Left Sidebar",
title: "Toggle Left Sidebar",
id: "toggle_left_sidebar",
command: ClosureWrapper(closure: {
self.toggleFirstPanel()
})
title: "Toggle Left Sidebar",
id: "toggle_left_sidebar",
command: ClosureWrapper(closure: {
self.toggleFirstPanel()
})
)

CommandManager.shared.addCommand(
Expand Down
8 changes: 7 additions & 1 deletion CodeEdit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,12 @@
</dict>
</array>
<key>GitHash</key>
<string>f41ffa79d66ee2ba1e65740b73577641b8ce7f1b</string>
<string>7a96cf534b4118d9c5f69164c85f06e501b322d2</string>
<key>SUEnableInstallerLauncherService</key>
<true/>
<key>SUFeedURL</key>
<string>https://codeeditapp.github.io/CodeEdit/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>/vAnxnK9wj4IqnUt6wS9EN3Ug69zHb+S/Pb9CyZuwa0=</string>
Comment thread
austincondiff marked this conversation as resolved.
</dict>
</plist>
12 changes: 10 additions & 2 deletions CodeEdit/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21223" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21223"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"/>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="lXw-SP-s0Z" customClass="SPUStandardUpdaterController"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="CodeEdit" id="1Xt-HY-uBw">
Expand All @@ -23,6 +25,12 @@
<menuItem title="CodeEdit Extensions..." id="saf-gh-uIY">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Check for Updates…" id="I48-Xe-LWa">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="lXw-SP-s0Z" id="Jzk-vc-Mun"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW">
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

import SwiftUI
import CodeEditUI
import Sparkle

/// A view that implements the `General` preference section
public struct GeneralPreferencesView: View {
@EnvironmentObject var updater: SoftwareUpdater

private let inputWidth: Double = 160
private let textEditorWidth: Double = 220
Expand Down Expand Up @@ -51,6 +53,7 @@ public struct GeneralPreferencesView: View {
revealFileOnFocusChangeToggle
shellCommandSection
autoSaveSection
updaterSection
}
}
}
Expand Down Expand Up @@ -251,6 +254,37 @@ private extension GeneralPreferencesView {
}
}

var updaterSection: some View {
PreferencesSection("Software Updates", hideLabels: false) {
VStack(alignment: .leading) {
Toggle("Automatically check for app updates", isOn: $updater.automaticallyChecksForUpdates)

Toggle("Include pre-release versions", isOn: $updater.includePrereleaseVersions)

Button("Check Now") {
updater.checkForUpdates()
}

Text("Last checked: \(lastUpdatedString)")
.font(.footnote)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}

private var lastUpdatedString: String {
if let lastUpdatedDate = updater.lastUpdateCheckDate {
return Self.formatter.string(from: lastUpdatedDate)
} else {
return "Never"
}
}

private static let formatter = configure(DateFormatter()) {
$0.dateStyle = .medium
$0.timeStyle = .medium
}

var autoSaveSection: some View {
PreferencesSection("Auto Save Behavior", hideLabels: false) {
Toggle("Automatically save changes to disk",
Expand Down Expand Up @@ -309,3 +343,9 @@ private extension GeneralPreferencesView {
}
}
}

func configure<Subject>(_ subject: Subject, configuration: (inout Subject) -> Void) -> Subject {
var copy = subject
configuration(&copy)
return copy
}
62 changes: 62 additions & 0 deletions CodeEditModules/Modules/AppPreferences/src/SoftwareUpdater.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// SoftwareUpdater.swift
// CodeEdit
//
// Created by Austin Condiff on 9/19/22.
//

import Foundation
import Sparkle

public class SoftwareUpdater: ObservableObject {
private let updater: SPUUpdater
@Published var automaticallyChecksForUpdates = false {
didSet {
updater.automaticallyChecksForUpdates = automaticallyChecksForUpdates
}
}
private var automaticallyChecksForUpdatesObservation: NSKeyValueObservation?
@Published var lastUpdateCheckDate: Date?
private var lastUpdateCheckDateObservation: NSKeyValueObservation?
@Published var includePrereleaseVersions = false {
didSet {
UserDefaults.standard.setValue(includePrereleaseVersions, forKey: "includePrereleaseVersions")
if includePrereleaseVersions {
updater.setFeedURL(.prereleaseAppcast)
} else {
updater.setFeedURL(.appcast)
}
}
}
public init() {
updater = SPUStandardUpdaterController(
startingUpdater: true,
updaterDelegate: nil,
userDriverDelegate: nil
).updater
automaticallyChecksForUpdatesObservation = updater.observe(
\.automaticallyChecksForUpdates,
options: [.initial, .new, .old],
changeHandler: { [unowned self] updater, change in
guard change.newValue != change.oldValue else { return }
self.automaticallyChecksForUpdates = updater.automaticallyChecksForUpdates
}
)
lastUpdateCheckDateObservation = updater.observe(
\.lastUpdateCheckDate,
options: [.initial, .new, .old],
changeHandler: { [unowned self] updater, _ in
self.lastUpdateCheckDate = updater.lastUpdateCheckDate
}
)
includePrereleaseVersions = UserDefaults.standard.bool(forKey: "includePrereleaseVersions")
}
func checkForUpdates() {
updater.checkForUpdates()
}
}

extension URL {
static let appcast = URL(string: "https://codeeditapp.github.io/CodeEdit/appcast.xml")!
static let prereleaseAppcast = URL(string: "https://codeeditapp.github.io/CodeEdit/appcast_pre.xml")!
}