mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Move modules to Modules folder.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// IndeterminateProgressWindowController.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Brent Simmons on 8/28/16.
|
||||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
|
||||
public func runIndeterminateProgressWithMessage(_ message: String) {
|
||||
|
||||
IndeterminateProgressController.beginProgressWithMessage(message)
|
||||
}
|
||||
|
||||
public func stopIndeterminateProgress() {
|
||||
|
||||
IndeterminateProgressController.endProgress()
|
||||
}
|
||||
|
||||
private final class IndeterminateProgressController {
|
||||
|
||||
static var windowController: IndeterminateProgressWindowController?
|
||||
static var runningProgressWindow = false
|
||||
|
||||
static func beginProgressWithMessage(_ message: String) {
|
||||
|
||||
if runningProgressWindow {
|
||||
assertionFailure("Expected !runningProgressWindow.")
|
||||
endProgress()
|
||||
}
|
||||
|
||||
runningProgressWindow = true
|
||||
windowController = IndeterminateProgressWindowController(message: message)
|
||||
NSApplication.shared.runModal(for: windowController!.window!)
|
||||
}
|
||||
|
||||
static func endProgress() {
|
||||
|
||||
if !runningProgressWindow {
|
||||
assertionFailure("Expected runningProgressWindow.")
|
||||
return
|
||||
}
|
||||
|
||||
runningProgressWindow = false
|
||||
NSApplication.shared.stopModal()
|
||||
windowController?.close()
|
||||
windowController = nil
|
||||
}
|
||||
}
|
||||
|
||||
private final class IndeterminateProgressWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet var messageLabel: NSTextField!
|
||||
@IBOutlet var progressIndicator: NSProgressIndicator!
|
||||
@objc dynamic var message = ""
|
||||
|
||||
convenience init(message: String) {
|
||||
self.init(window: nil)
|
||||
self.message = message
|
||||
Bundle.module.loadNibNamed("IndeterminateProgressWindow", owner: self, topLevelObjects: nil)
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
|
||||
progressIndicator.startAnimation(self)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// WebViewWindowController.swift
|
||||
// RSCore
|
||||
//
|
||||
// Created by Brent Simmons on 11/13/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
import WebKit
|
||||
|
||||
public final class WebViewWindowController: NSWindowController {
|
||||
|
||||
@IBOutlet private var webview: WKWebView!
|
||||
private var title: String!
|
||||
|
||||
public convenience init(title: String) {
|
||||
self.init(window: nil)
|
||||
self.title = title
|
||||
Bundle.module.loadNibNamed("WebViewWindow", owner: self, topLevelObjects: nil)
|
||||
}
|
||||
|
||||
public override func windowDidLoad() {
|
||||
|
||||
window!.title = title
|
||||
}
|
||||
|
||||
public func displayContents(of path: String) {
|
||||
|
||||
// We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder.
|
||||
|
||||
let _ = self.window
|
||||
|
||||
let fileURL = URL(fileURLWithPath: path)
|
||||
let folderURL = fileURL.deletingLastPathComponent()
|
||||
|
||||
webview.loadFileURL(fileURL, allowingReadAccessTo: folderURL)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user