Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 4104b31

Browse files
Version 3.0 BETA 4 final commit
- Code imprrovements and polish - Improvved plist edit open menu in EFI partition mounter - Implemented translations for the most important ui dialogs - Improoved icon detection for disk drives - improoved diagnosrtics mode code - added support for touch id on EFI partition mounter - remooved unused libraries calls
1 parent d5df23c commit 4104b31

25 files changed

+653
-505
lines changed

EFI Partition Mounter/EFI Partition Mounter/EFIPartitionMounterModel.swift

Lines changed: 285 additions & 285 deletions
Large diffs are not rendered by default.

EFI Partition Mounter/EFI Partition Mounter/EFIPartitionMounterUIClasses.swift

Lines changed: 44 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,28 @@ public class EFIPartitionToolInterface{
1717

1818
public let id: String = "EFIPartitionItem"
1919

20-
public let tileHeight: CGFloat = 60
21-
22-
let titleLabel = NSTextField()
23-
let placeHolderLabel = NSTextField()
24-
25-
let mountButton = NSButton()
26-
let unmountButton = NSButton()
27-
28-
let editOtherConfigButton = NSButton()
20+
public let titleLabel = NSTextField()
2921

30-
var configOpenMenu: NSMenu = NSMenu()
22+
private let placeHolderLabel = NSTextField()
23+
private let mountButton = NSButton()
24+
private let unmountButton = NSButton()
25+
private let editOtherConfigButton = NSButton()
26+
private var configOpenMenu: NSMenu = NSMenu()
27+
private let showInFinderButton = NSButton()
28+
private let ejectButton = NSButton()
29+
private let coverView = NSView()
30+
private let spinner = NSProgressIndicator()
3131

32-
let showInFinderButton = NSButton()
33-
let ejectButton = NSButton()
34-
let coverView = NSView()
35-
36-
let spinner = NSProgressIndicator()
3732
var isMounted = false
38-
3933
var configType: EFIPartitionToolTypes.ConfigLocations! = .cloverConfigLocation
40-
4134
var isEjectable = false
42-
4335
var bsdid: String = ""
44-
4536
var partitions: [PartitionItem] = []
46-
4737
var isBar = false
4838

49-
var alreadyDrwn = false
39+
public let tileHeight: CGFloat = 60
40+
41+
private var alreadyDrwn = false
5042

5143
public override func draw(_ dirtyRect: NSRect) {
5244
super.draw(dirtyRect)
@@ -137,23 +129,30 @@ public class EFIPartitionToolInterface{
137129
editOtherConfigButton.font = NSFont.systemFont(ofSize: 13)
138130
editOtherConfigButton.isContinuous = true
139131
editOtherConfigButton.target = self
140-
//editOtherConfigButton.action = #selector(EFIPartitionItem.editConfigOther(_:))
141132

142133
editOtherConfigButton.action = #selector(EFIPartitionItem.openConfigMenu(_:))
143134

144135
self.addSubview(editOtherConfigButton)
145136

146-
configOpenMenu = NSMenu()//(title: EFIPMTextManager.getViewString(context: self, stringID: "configMenuTitle"))
137+
configOpenMenu = NSMenu()
147138

148139
for c in 0..<appMenu.list.count{
149-
let itm = NSMenuItem()//NSMenuItem(title: appMenu.list[c].name, action: #selector(editConfigGeneric(_:)), keyEquivalent: "")
150-
itm.title = appMenu.list[c].name
151-
itm.tag = c
152-
itm.isEnabled = true
153-
itm.isHidden = false
154-
itm.target = self
155-
itm.action = #selector(editConfigGeneric(_:))
140+
let name = appMenu.list[c].name
141+
142+
var itm: NSMenuItem = NSMenuItem()
156143

144+
if name == "Separator"{
145+
itm = NSMenuItem.separator()
146+
itm.isEnabled = false
147+
}else{
148+
itm.title = name
149+
itm.tag = c
150+
itm.isEnabled = true
151+
itm.isHidden = false
152+
itm.target = self
153+
itm.action = #selector(editConfigGeneric(_:))
154+
}
155+
157156
configOpenMenu.insertItem(itm, at: c)
158157
}
159158

@@ -229,11 +228,6 @@ public class EFIPartitionToolInterface{
229228

230229
distance = 0
231230

232-
/*
233-
if partCount < 3{
234-
distance = (tileWidth + margin) / CGFloat(partCount)
235-
}*/
236-
237231
for partition in partitions{
238232
partition.frame.size = CGSize(width: tileWidth, height: tileHeight)
239233

@@ -255,17 +249,6 @@ public class EFIPartitionToolInterface{
255249

256250
}
257251

258-
/*
259-
for c in self.subviews{
260-
if let l = c as? NSTextField{
261-
l.drawsBackground = true
262-
(l as NSView).backgroundColor = (l.superview! as NSView).backgroundColor
263-
}
264-
265-
//c.backgroundColor = .red
266-
}*/
267-
268-
269252
alreadyDrwn.toggle()
270253

271254
checkMounted()
@@ -329,43 +312,21 @@ public class EFIPartitionToolInterface{
329312

330313
#if !macOnlyMode
331314

332-
@objc private func editConfigOther(_ sender: Any){
315+
@objc private func openConfigMenu(_ sender: Any){
333316

334317
if configType == nil{
335318
return
336319
}
337320

338-
339-
DispatchQueue.global(qos: .background).async{
340-
guard let mountPoint = dm.getMountPointFromPartitionBSDID(self.bsdid) else { return }
341-
342-
var configLocation = mountPoint
343-
344-
for loc in EFIPartitionToolTypes.ConfigLocations.allCases{
345-
if !FileManager.default.fileExists(atPath: mountPoint + loc.rawValue){ continue }
346-
347-
configLocation += loc.rawValue
348-
break
349-
}
350-
351-
DispatchQueue.main.sync{
352-
353-
if NSWorkspace.shared().openFile(configLocation){ return }
354-
355-
//msgBoxWarning("Impossible to open \"config.plist\"!", "Impossible to find an app to open the \"config.plist\" file!")
356-
357-
msgboxWithManagerGeneric(EFIPMTextManager, self, name: "impossible", parseList: nil, style: .warning, icon: IconsManager.shared.warningIcon)
358-
}
359-
}
360-
361-
}
362-
363-
@objc private func openConfigMenu(_ sender: Any){
364321
configOpenMenu.popUp(positioning: nil, at: editOtherConfigButton.frame.origin, in: self)
365322
}
366323

367324
@objc private func editConfigGeneric(_ sender: Any){
368325

326+
if configType == nil{
327+
return
328+
}
329+
369330
guard let sen = sender as? NSMenuItem else { return }
370331
let target = sen.tag
371332

@@ -380,21 +341,23 @@ public class EFIPartitionToolInterface{
380341

381342
DispatchQueue.main.sync{
382343

383-
if item.installedAppName.isEmpty{
384-
344+
switch item.installedAppName{
345+
case "":
385346
if NSWorkspace.shared().openFile(configLocation){ return }
386347

387348
msgboxWithManagerGeneric(EFIPMTextManager, self, name: "impossible", parseList: nil, style: .warning, icon: IconsManager.shared.warningIcon)
388-
389-
}else{
390-
349+
break
350+
case "{openLink}" :
351+
NSWorkspace.shared().open(URL(string: item.download)!)
352+
break
353+
default:
391354
if NSWorkspace.shared().openFile(configLocation, withApplication: item.installedAppName){ return }
392-
393-
let list = ["{appName}" : item.name]
355+
356+
let list = ["{appName}" : item.installedAppName]
394357
if dialogWithManagerGeneric(EFIPMTextManager as TextManagerGet, self, name: "download", parseList: list){
395358
NSWorkspace.shared().open(URL(string: item.download)!)
396359
}
397-
360+
break
398361
}
399362

400363
}

TINU.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
/* End PBXFrameworksBuildPhase section */
264264

265265
/* Begin PBXGroup section */
266-
C600803C251A910800FE35E2 /* Json */ = {
266+
C600803C251A910800FE35E2 /* JSON */ = {
267267
isa = PBXGroup;
268268
children = (
269269
C6188D972513828E00BCBC51 /* AppDownloadsEn.json */,
@@ -273,7 +273,7 @@
273273
C68C79F12505205A00BBDA37 /* TextAssetsIt.json */,
274274
C63F035D24E1091400F950B4 /* ProgressBarSettings.json */,
275275
);
276-
name = Json;
276+
name = JSON;
277277
sourceTree = "<group>";
278278
};
279279
C60C40C520CCAD9C00258574 /* Managers */ = {
@@ -373,14 +373,14 @@
373373
C649CC90211A4EE100A6B47B /* EFIPartitionMounterTool */ = {
374374
isa = PBXGroup;
375375
children = (
376+
C660D19A2529BB3B0027FCA0 /* JSON */,
376377
C647B3AD211D18950024B9A1 /* EFIPartitionMounterTool.storyboard */,
377378
C647B399211CF2C40024B9A1 /* EFIPartitionMounterModel.swift */,
378379
C660D19D2529F0A70027FCA0 /* EFIPartitionMounterTextManager.swift */,
379380
C647B395211CF2C40024B9A1 /* EFIPartitionMounterTypes.swift */,
380381
C647B39A211CF2C40024B9A1 /* EFIPartitionMounterUIClasses.swift */,
381382
C647B396211CF2C40024B9A1 /* EFIPartitionMounterViewController.swift */,
382383
C647B397211CF2C40024B9A1 /* EFIPartitionMounterWindowController.swift */,
383-
C660D19A2529BB3B0027FCA0 /* JSON */,
384384
);
385385
name = EFIPartitionMounterTool;
386386
sourceTree = "<group>";
@@ -463,13 +463,13 @@
463463
C6DE523A247EB6EA00FBD2E1 /* TINU.entitlements */,
464464
C6DF046E1F4F33C500D200B1 /* Info.plist */,
465465
C691BFED1F6DEEA800589EF8 /* Assets.xcassets */,
466+
C600803C251A910800FE35E2 /* JSON */,
467+
C6553A941F5F83DC0048965D /* Resources */,
466468
C6DF046B1F4F33C500D200B1 /* Main.storyboard */,
467469
C698B47D204CDAE5007B3CD8 /* MacrosReference.swift */,
468470
C6DF04651F4F33C500D200B1 /* AppDelegate.swift */,
469471
C60A461423A8571E009ADF4D /* ToDo.swift */,
470472
C649CC8F211A4ECF00A6B47B /* Tools */,
471-
C600803C251A910800FE35E2 /* Json */,
472-
C6553A941F5F83DC0048965D /* Resources */,
473473
C60D39B51F5EB48000D94834 /* WindowsControllers */,
474474
C60D39B71F5EB4C800D94834 /* ViewControllers */,
475475
C60D39B61F5EB4A000D94834 /* OtherCode */,

TINU/.DS_Store

0 Bytes
Binary file not shown.

TINU/AllertFunctionsWithTextManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2020 Pietro Caruso. All rights reserved.
77
//
88

9-
import AppKit
9+
import Cocoa
1010

1111
public func msgboxWithManagerGeneric(_ manager: TextManagerGet, _ handle: ViewID, name: String, parseList: [String: String]! = nil, style: NSAlertStyle = NSAlertStyle.warning, icon: NSImage? = IconsManager.shared.warningIcon){
1212
var title = manager.getViewString(context: handle, stringID: name + "Title")

TINU/ChooseSideViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ChooseSideViewController: GenericViewController, ViewID {
8282
//ui setup
8383

8484
//print(TextManager!)
85-
print(CodableCreation<TINUTextsManagerStruct>.getEncoded(TextManager!)!)
85+
//print(CodableCreation<TINUTextsManagerStruct>.getEncoded(TextManager!)!)
8686

8787
createUSBButton.upperImage.image = IconsManager.shared.removableDiskIcon //NSImage(named: "Removable")
8888
createUSBButton.upperTitle.stringValue = TextManager.getViewString(context: self, stringID: "openInstaller")//"Create a bootable\nmacOS installer"

TINU/ChoseAppViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,18 @@ class ChoseAppViewController: GenericViewController, ViewID {
146146
}
147147

148148
if open.urls.isEmpty{
149-
msgBoxWarning("Error while opening the file", "No files choosen")
149+
//msgBoxWarning("Error: no files chosen!", "No files seems to have been chosen , proably this is an internal error")
150+
151+
msgboxWithManager(self, name: "errorOpening")
152+
150153
continue
151154
}
152155

153156
guard var path = open.urls.first?.path else {
154-
msgBoxWarning("Error while opening the file", "Impossible to obtain the file's location")
157+
//msgBoxWarning("Error while opening the file's path", "Impossible to obtain the file's location for some reason")
158+
159+
msgboxWithManager(self, name: "errorPath")
160+
155161
continue
156162
}
157163

TINU/ChoseDriveViewController.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,28 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
153153
prt.size = d.Size
154154

155155
log(" Item display name is: \(drivei.volume.stringValue)")
156+
157+
drivei.image.image = nil
158+
156159
if !prt.isDrive{
157160
if item!.isMounted(){
158161
drivei.image.image = NSWorkspace.shared().icon(forFile: item.MountPoint!)
159162
}
160163
}else{
164+
var property = "Ejectable"
165+
166+
if #available(OSX 10.12, *){
167+
property = "RemovableMediaOrExternalDevice"
168+
}
169+
170+
if let i = dm.getDevicePropertyInfoBoolNew(prt.bsdName, propertyName: property) {
171+
if !i{
172+
drivei.image.image = IconsManager.shared.internalDiskIcon
173+
}
174+
}
175+
}
176+
177+
if drivei.image.image == nil{
161178
drivei.image.image = IconsManager.shared.removableDiskIcon
162179
}
163180

@@ -212,6 +229,7 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
212229
//just need to know which is the boot volume, to not allow the user to choose it
213230
let boot = dm.getDeviceBSDIDFromMountPoint("/")!
214231
var boot_drive = [dm.getDriveBSDIDFromVolumeBSDID(volumeID: boot)]
232+
let execp = Bundle.main.executablePath!
215233

216234
print("Boot volume BSDID: \(boot)")
217235

@@ -234,7 +252,7 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
234252
print("The boot drive devices are: ")
235253
print(boot_drive)
236254

237-
for d in data.AllDisksAndPartitions{
255+
alldiskFor: for d in data.AllDisksAndPartitions{
238256
log(" Drive: \(d.DeviceIdentifier)")
239257

240258
if boot_drive.contains(d.DeviceIdentifier){
@@ -266,6 +284,11 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
266284
continue
267285
}
268286

287+
if execp.contains(p.MountPoint!) {
288+
log(" TINU is running from this partition, skipping to the next drive")
289+
continue alldiskFor
290+
}
291+
269292
log(" Partition meets all the requirements, it will be added to the dectected partitions list")
270293

271294
self.makeAndDisplayItem(p, &drives)

TINU/ClassExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2017 Pietro Caruso. All rights reserved.
77
//
88

9-
import AppKit
9+
import Cocoa
1010

1111
//this file just contains some usefoul extensions and methods for system classes
1212

TINU/ConfigMenuAppsEn.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"installedAppName" : "Clover Configurator"
77
},
88
{
9-
"name" : "OpenCore Configurator",
9+
"name" : "OpenCore Configurator (May break your config.plist)",
1010
"download" : "https://mackie100projects.altervista.org/download-opencore-configurator/",
1111
"installedAppName" : "OpenCore Configurator"
1212
},
@@ -16,10 +16,30 @@
1616
"installedAppName" : "Xcode"
1717
},
1818
{
19-
"name" : "BBEdit",
19+
"name" : "BBEdit (Contains in-app purchases)",
2020
"download" : "macappstores:\/\/itunes.apple.com/app/bbedit/id404009241?mt=12",
2121
"installedAppName" : "BBEdit"
2222
},
23+
{
24+
"name" : "PlistEdit Pro (May require a paid license)",
25+
"download" : "https://www.fatcatsoftware.com/plisteditpro/",
26+
"installedAppName" : "PlistEdit Pro"
27+
},
28+
{
29+
"name" : "Separator",
30+
"download" : "",
31+
"installedAppName" : ""
32+
},
33+
{
34+
"name" : "Get ProperTree",
35+
"download" : "https://github.com/corpnewt/propertree",
36+
"installedAppName" : "{openLink}"
37+
},
38+
{
39+
"name" : "Separator",
40+
"download" : "",
41+
"installedAppName" : ""
42+
},
2343
{
2444
"name" : "Other app ...",
2545
"download" : "",

0 commit comments

Comments
 (0)