Skip to content

Commit b62ce74

Browse files
committed
Many changes to manage the theme editor.
Consult the CHANGELOG for the list of changes.
1 parent 26c65e9 commit b62ce74

File tree

329 files changed

+14213
-9712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+14213
-9712
lines changed

Application/AppDelegate.swift

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import Cocoa
2424
import Syntax_Highlight_XPC_Service
2525

26+
typealias ExampleItem = (url: URL, title: String, uti: String)
27+
2628
@NSApplicationMain
2729
class AppDelegate: NSObject, NSApplicationDelegate {
2830
lazy var connection: NSXPCConnection = {
@@ -56,7 +58,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5658
}
5759

5860
func applicationDidBecomeActive(_ notification: Notification) {
59-
if firstAppear && NSApplication.shared.windows.count == 0, let menu = NSApp.menu?.item(at: 0)?.submenu?.item(withTag: 100), let a = menu.action {
61+
if firstAppear, NSApplication.shared.windows.first(where: { $0.contentViewController is ViewController }) == nil, let menu = NSApp.menu?.item(at: 0)?.submenu?.item(withTag: 100), let a = menu.action {
62+
// Open the settings window if there are no windows opened.
6063
NSApp.sendAction(a, to: menu.target, from: menu)
6164
}
6265
firstAppear = false
@@ -97,7 +100,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
97100
if uti.isValid {
98101
fileTypes.append(uti)
99102
} else {
100-
print("Ignoring \(type) uti.")
103+
print("Ignoring `\(type)` uti because it has no mime or file extension associated.")
101104
}
102105
}
103106

@@ -108,5 +111,48 @@ class AppDelegate: NSObject, NSApplicationDelegate {
108111

109112
return fileTypes
110113
}
114+
115+
/// Get the list of available source file example.
116+
func getAvailableExamples() -> [ExampleItem] {
117+
// Populate the example files list.
118+
var examples: [ExampleItem] = []
119+
if let examplesDirURL = Bundle.main.url(forResource: "examples", withExtension: nil) {
120+
let fileManager = FileManager.default
121+
if let files = try? fileManager.contentsOfDirectory(at: examplesDirURL, includingPropertiesForKeys: nil, options: [.skipsHiddenFiles]) {
122+
for file in files {
123+
let title: String
124+
if let uti = UTI(URL: file) {
125+
title = uti.description + " (." + file.pathExtension + ")"
126+
examples.append((url: file, title: title, uti: uti.UTI))
127+
} else {
128+
title = file.lastPathComponent
129+
examples.append((url: file, title: title, uti: ""))
130+
}
131+
132+
}
133+
examples.sort { (a, b) -> Bool in
134+
a.title < b.title
135+
}
136+
}
137+
}
138+
return examples
139+
}
140+
141+
@IBAction func openApplicationSupportFolder(_ sender: Any) {
142+
service?.getApplicationSupport(reply: { (url) in
143+
if let u = url, FileManager.default.fileExists(atPath: u.path) {
144+
// Open the Finder to the application support folder.
145+
NSWorkspace.shared.activateFileViewerSelecting([u])
146+
} else {
147+
let alert = NSAlert()
148+
alert.messageText = "Attention"
149+
alert.informativeText = "The application support folder don't exists."
150+
alert.addButton(withTitle: "Close")
151+
alert.alertStyle = .informational
152+
153+
alert.runModal()
154+
}
155+
})
156+
}
111157
}
112158

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "M_on.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"template-rendering-intent" : "template",
14+
"preserves-vector-representation" : true
15+
}
16+
}
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "M.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"template-rendering-intent" : "template",
14+
"preserves-vector-representation" : true
15+
}
16+
}
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
"images" : [
33
{
44
"idiom" : "universal",
5-
"filename" : "WorkingCopyNavigatorTemplate_Normal.png",
5+
"filename" : "I.pdf",
66
"scale" : "1x"
77
},
88
{
99
"idiom" : "universal",
10-
"filename" : "WorkingCopyNavigatorTemplate_Normal@2x.png",
1110
"scale" : "2x"
1211
},
1312
{
Binary file not shown.
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "A.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
},
12+
"properties" : {
13+
"template-rendering-intent" : "template",
14+
"preserves-vector-representation" : true
15+
}
16+
}
Binary file not shown.

0 commit comments

Comments
 (0)